“this” keyword is used in many contexts but we will discuss the most common usage. “this” keyword is used to refer current class instance variable and is also used to invoke the current class constructor.
class Employee { int id; String name; Employee(int id,String name) { this.id = id; this.name = name; } void show() { System.out.println(id+” “+name); } public static void main(String args[]) { Employee e1 = new Employee(256,”James”); Employee e2 = new Employee(256,”Gosling”); e1.show(); e2.show(); } }