Is there any difference between the call to getName()
on line 8 and that on line 9.
If yes, then what is it?
This might be very simple but I did my Google search and the only SO result I got was about using this
with a field, and not with a method.
class CallingInstanceMethodWithAndWithoutThis {
private String getName() {
return "Zarah";
}
private void printGetName() {
System.out.println(getName());
System.out.println(this.getName());
}
public static void main(String [] args) {
new CallingInstanceMethodWithAndWithoutThis().printGetName();
}
}
There is no difference, it is just a coding convention to use. Moreover you can ask Eclipse for instance to remove automatically "this" when not needed as a Save Action.