The following code is considered invalid by the compiler:
class Foo {
void foo(String foo) { ... }
}
class Bar extends Foo {
@Override
void foo(Obje
The problem with your code is that you are telling compiler that foo
method in Bar
class is overridden from parent class of Bar, i.e. Foo. Since overridden methods must have same signature
, but in your case, according to syntax it is an overloaded method as you have changed the parameter in foo method of Bar class.