class S2{
void m(S2 obj){
System.out.println("method is invoked");
}
void p(){
m(this); //instead of this keyword what can i use?
}
public static void main(String args[]){
S2 s1 = new S2();
s1.p();
}
}
在上述程序中,我可以用什么代替该关键字?
答案 0 :(得分:0)
这已经习惯于引用当前类的实例变量。
class S2{
void m(S2 obj){
System.out.println("method is invoked");
}
void p(S2 obj){
m(obj); //instead of this keyword you can pass a reference and use, bad practice but just to help you for your understanding.
}
public static void main(String args[]){
S2 s2 = new S2();
s2.p(s2);
}
}