Here, I am gonna explore coding, Debugging, Error fixing, My articles and other technical posts. So stay tuned.

Use of this keyword in Java | Java This Keyword - Java Programming

3 comments

This key word 

Lets create class A and in this class let me define a constructor A which takes a int value in a variable and in the class A there is a Private instance variable. As shown in figure below.


And it also have another show method to display massage. 
So focus on constructor A what we are doing there is we assigning the value of a in the variable x.
so this will work correctly.


But what if we do this.


Now compiler will be confused and it make the instance variable in the constructor to Local Variable.
To over come this confusion we use THIS keyword.



Thank You

  

3 comments :

  1. Hi, I've been experiencing difficulties with learning Java. I'm currently taking a Java course at a community college and I'm finding that my level of satisfaction/success in Java is less compared to C#. A friend of mine recommends me this service https://www.assignmentexpert.com/programming. They provide the help with java projects from experienced, degree-holding professionals for affordable price. Have you tried it?

    ReplyDelete