Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java this keyword

Tags:

java

this

I have read that in Java you don't have to explicitly bind the this keyword to object, it is done by interpreter. It is opposite to Javascript where you always have to know the value of this. But where is this in Java is pointing - to class or object ? Or does it vary ? This question is a part of my attempt to understand basic OO concepts and design patterns so I can apply them to Javascript. Thank you.

like image 890
Miroslav Trninic Avatar asked Mar 27 '26 19:03

Miroslav Trninic


1 Answers

In Java, this always refers to an object and never to a class.

like image 94
David Heffernan Avatar answered Mar 31 '26 07:03

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!