I want to remove a method from a class that is present in it's super class. I can deprecate the superclass method using the @Deprecated
annotation, but it is still accessible in the subclass.
Eg:
public class Sample {
void one() {}
void two() {}
@Deprecated
void three() {}
}
class Sample2 extends Sample {
@Override
void one() {}
public static void main() {
Sample2 obj = new Sample2();
obj.one();
obj.two();
obj.three();// I do not want to access this method through the sample 2 object.
}
}
While using the Sample2
object I only want methods one
and two
to be available. Please advice on how to do this.
Thanks a lot.