Deprecation of a method in an interface (by using @Deprecated) does not prevent methods from being implemented in classes. It does not generate a compiler error in the class implementing the deprecated method. It simply lets the class author know (at compile time) that this method is deprecated as of this moment and also that it should be avoided if possible (as it may be removed in the future). In fact it does not even generate a warning when the class author is overriding the method but only when somebody is trying to call the method. This makes sense because if the class author does not override the method, the class will remain abstract.
To see this warning though you need to have a reference of the interface type and not of the implementing class type.
Try this example, it should make it clearer.
interface Testable {
@Deprecated
void test1();
void test2();
}
public class Test005 implements Testable {
@Override
public void test1(){
System.out.println("hello 1");
}
@Override
public void test2(){
System.out.println("hello 2");
}
public static void main(String[] args){
Test005 tA = new Test005();
tA.test1(); // no warning
tA.test2(); // no warning
Testable tB = new Test005();
tB.test1(); // deprecation warning
tB.test2(); // no warning
}
}