Difference Between this and this() in Java Last Updated : 12 Mar, 2021 Comments Improve Suggest changes Like Article Like Report In Java, both this and this() are completely different from each other. this keyword is used to refer to the current object, i.e. through which the method is called.this() is used to call one constructor from the other of the same class.The below table shows the point-to-point difference between both this keyword and this(). thisthis()this keyword is used with the objects only. this() is used with constructors only. It refers to the current object. It refers to the constructor of the same class whose parameters matches with the parameters passed to this(parameters). Dot(.) operator is used to access the members. For example, this.variableName; No Dot(.) operator is used. Only the matching parameters are passed. It is used to differentiate between the local variable and the instance variable in the method. It is used to refer to the constructor belonging to the same class. See the code below, which describes the utilization of this keyword. Java import java.io.*; public class Student { private String name; private int age; // Note that in the Constructor below "this keyword" is // used to differentiate between the local variable and // the instance variable. public Student(String name, int age) { // Assigns the value of local name variable // to the name(instance variable). this.name = name; // Assigns the value of local Age variable // to the Age(instance variable). this.age = age; } public void show() { System.out.println("Name = " + this.name); System.out.println("Age = " + this.age); } public static void main(String[] args) { // Creating new instance of Student Class Student student = new Student("Geeks", 20); student.show(); } } OutputName = Geeks Age = 20 Now take a look at the code below which describes the use of this(). Java import java.io.*; public class Student { private String name; private int age; // Constructor 1 with String as parameter. public Student(String name) { // This line of code calls the second constructor. this(20); System.out.println("Name of Student : " + name); } // Constructor 2 with int in parameter. public Student(int age) { System.out.println("Age of student = " + age); } // Constructor 3 with no parameters. public Student() { // This line calls the first constructor. this("Geeks"); } public static void main(String[] args) { // This calls the third constructor. Student student = new Student(); } } OutputAge of student = 20 Name of Student : Geeks Please note that this() should always be the first executable statement in the constructor. Otherwise, the program will give compile time error. Comment More info A ankitsinghrajput Follow Improve Article Tags : Java Difference Between Explore Java BasicsIntroduction to Java4 min readJava Programming Basics9 min readJava Methods7 min readAccess Modifiers in Java6 min readArrays in Java9 min readJava Strings8 min readRegular Expressions in Java7 min readOOP & InterfacesClasses and Objects in Java10 min readAccess Modifiers in Java6 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface11 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java6 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling8 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking15+ min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples8 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz | Level Up Your Java Skills1 min readTop 50 Java Project Ideas For Beginners and Advanced [Update 2025]15+ min read Like