The same statement may not have multiple labels with the same name. For
example, the following program has an error:
class C {
void f() {
int x;
a: a: x = 0;
}
}
The Java compiler does not indicate this as an error.
I have already discussed this with Guy Steele who agrees that this is
an error because the statement "a: x = 0;" is considered to be nested
within the statement "a: a: x = 0;".
example, the following program has an error:
class C {
void f() {
int x;
a: a: x = 0;
}
}
The Java compiler does not indicate this as an error.
I have already discussed this with Guy Steele who agrees that this is
an error because the statement "a: x = 0;" is considered to be nested
within the statement "a: a: x = 0;".
- duplicates
-
JDK-1241001 labels with the same name are allowed for nested blocks
- Closed