It is used with the constructor and used to refer to the current object of the constructor using this keyword. Keyword 'THIS' in Java is a reference variable that refers to the current object. It can be used to refer current class instance variable. It can be used to invoke or initiate current class constructor.
In respect to this, why do we use new keyword in Java?
new is a Java keyword. It creates a Java object and allocates memory for it on the heap. new is also used for array creation, as arrays are also objects. Java Programming/Creating Objects.
What is the purpose of this keyword in Java?
Which can be used inside method or constructor of class. It(this) works as a reference to a current object whose method or constructor is being invoked. this keyword can be used to refer any member of current object from within an instance method or a constructor. In Java "this" is a predefined variable.
What is the use of new operator in Java?
new operator in Java. When you are declaring a class in java, you are just creating a new data type. A class provides the blueprint for objects. This variable does not define an object. Instead, it is simply a variable that can refer to an object.