B
Bjorn-Ove.Heimsund
Hi,
I've got an issue where an inner class has a method of the same name
(but different signature) as that of its enclosing class:
public class Foo {
class FooBar {
void foo(int i) { foo(i,i); }
}
int foo(int i, int j) { return i+j; }
}
Compiling this gives an error, indicating a clash between
Foo.foo(int, int) and Foo.FooBar.foo(int). Changing either method name
removes this issue. I've verified this on both vanilla javac and jikes.
I've perused the Java Language Specification, but haven't found a reason
why my code snippet does not compile. Does anyone know why the compiler
should not accept this?
I've got an issue where an inner class has a method of the same name
(but different signature) as that of its enclosing class:
public class Foo {
class FooBar {
void foo(int i) { foo(i,i); }
}
int foo(int i, int j) { return i+j; }
}
Compiling this gives an error, indicating a clash between
Foo.foo(int, int) and Foo.FooBar.foo(int). Changing either method name
removes this issue. I've verified this on both vanilla javac and jikes.
I've perused the Java Language Specification, but haven't found a reason
why my code snippet does not compile. Does anyone know why the compiler
should not accept this?