My teacher says that when I try to access an instance variable within a method I should always use the this
keyword, otherwise I would perform a double search. A local scope search and then an instance scope search.
Example:
public class Test(){
int cont=0;
public void Method(){
System.out.println(cont);//Should I use This.cont instead?
}
}
I hope he is wrong, but I can't find any argument.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…