The following code produces an error. It should be legal to declare
a method and a variable with the same name.
class test {
int foo;
void foo() {
}
void bar(test t) {
t.foo = 1;
t.foo();
}
}
test.java:9: Attempt to reference method foo in class test as an instance variable.
t.foo = 1;
^
1 error