//cls_a is defined by system framework, so we cannot change its definition
public class cls_a {
public void method_a();
}
//I add a new cls_b implemenation and would like to
//add a new method_a(int) function
//and prevent client side to access cls_a.method_a()
public class cls_b extends cls_a {
public void method_a(int a) {
//do something for a
method_a();
}
}
//client side
cls_b b = new cls_b();
b.method_a(2); //it's okay
b.method_a(); //should give something error when compiling code
我想设计cls_b
使Java编译器在客户端调用时会出错b.method_a()
。任何人都知道如何在Java中做到这一点?