//Example of this keyword that you return as a statement from the method
class ClassMe{
ClassMe getClassMe(){
return this;
}
void display(){
System.out.println("Don't confuse");
}
}
class MainClass{
public static void main(String args[]){
new ClassMe().getClassMe().display();
}
}
/*
<b>this keyword can be used to return current class instance:</b>
We can return this keyword as an statement from the method.
In such case, return type of the method must be the class type (non-primitive).
*/
Don't confuse
Press any key to continue . . .
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.