I have read many answers but I am still not clear on it. Below is the sample code:
package test;
public class ThisDemo {
int first,second;
public void thisData(int a,int b) {
first=a;
second=b;
}
public void showData() {
System.out.println(first +" "+second);
}
public static void main(String[] args) {
ThisDemo demo=new ThisDemo();
demo.thisData(10, 20);
demo.showData();
ThisDemo demo1=new ThisDemo();
demo1.thisData(100, 200);
demo1.showData();
}
}
the above code compiles, runs and gives expected output then what is the point in having this keyword? Is it used only if the class variables and method variables are same? If yes, then is it a standard that is followed?