I have a question.
Please don't mark it as duplicate, Go through the question once. I can't find an answer to this specific situation/condition, If you feel it has a specific answer then only mark duplicate. Marking it duplicate makes my question remain a question without an answer.
What's the difference between calling a method with/without this as a keyword. Which one is better?
The question specifically applies for a single class.
Please have a look at the sample code below to fully understand the question.
public class ThisSample {
public static void main(String[] args) {
ThisSample sample = new ThisSample();
sample.methodOne();
}
public void methodOne() {
System.out.println("Method 1 called");
this.methodTwo(); //Line 1
methodTwo(); // Line 2
}
public void methodTwo() {
System.out.println("Method 2 called");
}
}
What difference (Advantage/disadvantage/implication) does the 2 lines (Line 1 & Line 2) in the code make?
Thanks & Regards, Yadvendra