, @Override , , .
, :
public interface MyInterface {
public void doSomething();
}
The class implementing this interface is below ( MyClassA):
public MyClassA implements MyInterface {
public void doSomething() {
System.out.println("This is from MyClassA");
}
}
Then the class below extends MyClassAand overrides doSomething, and so I would add an annotation @Override.
public MyClassB extends MyClassA implements MyInterface {
@Override
public void doSomething() {
System.out.println("This is from MyClassB");
}
}
In any case, I would not do this (regardless of whether it is allowed), since it violates the idea of redefining something - you implement, not redefine, the interface:
public MyClassA implements MyInterface {
@Override
public void doSomething() {
System.out.println("This is from MyClassA");
}
}
source
share