Posts

Showing posts with the label this variable

Java this Keyword

Image
Java this Keyword: this Variable, this Method, this Constructor (With Examples) ✨ Quick Summary In this post, you’ll learn what the this keyword means in Java and why it is used. We will cover this variable , this method , and this constructor with simple examples. Java this keyword OOP In our previous post, we learned about the static keyword in Java. Now, let’s learn another very important keyword used in constructors and OOP: this . 1) What is this Keyword in Java? The this keyword in Java refers to the current object . ✅ Simple meaning: this = the current class object 2) Why Do We Use this Keyword? We use this keyword mainly for: ✅ To differentiate between instance variables and parameters ✅ To call current class methods ✅ To call current class constructor ( constructor chaining ) 3) this Keyword to...