+ 1
What is the 'this' keyword?
3 Respuestas
+ 2
In java, this is a reference variable that refers to the current object.
+ 1
"this" refers to the current object
For example:
public class SomeClass {
private int hehe = 321;
public void printHehe() {
System.out.printLn(this.hehe);
// This would print 321
// "this refers to the current object - instance of SomeClass
}
}
// of course you would need to call new SomeClass() and printHehe(), but this is just a demonstration
0
"This" is a implicit reference variable which holds the reference id of current object.
It is also called implicit pointer in JAVA.We never use 'This' keyword into a static method or in a block.