Consider code like this:
---
public class T {
{
String v = "";
Integer v = 0;
System.err.println(v.byteValue());
}
}
---
The errors for this code is:
---
$ javac T.java
T.java:4: error: variable v is already defined in instance initializer of class T
Integer v = 0;
^
T.java:5: error: cannot find symbol
System.err.println(v.byteValue());
^
symbol: method byteValue()
location: variable v of type String
2 errors
---
The first error is correct, of course, but the second error seems unnecessary - the variable is "redeclared", so it seems from the point of redeclaration, "v" should mean the new variable.
---
public class T {
{
String v = "";
Integer v = 0;
System.err.println(v.byteValue());
}
}
---
The errors for this code is:
---
$ javac T.java
T.java:4: error: variable v is already defined in instance initializer of class T
Integer v = 0;
^
T.java:5: error: cannot find symbol
System.err.println(v.byteValue());
^
symbol: method byteValue()
location: variable v of type String
2 errors
---
The first error is correct, of course, but the second error seems unnecessary - the variable is "redeclared", so it seems from the point of redeclaration, "v" should mean the new variable.