Java this.classProperty versus classProperty incase argument variable name clashes?
<p>Can someone please explain output 0 in case of first constructor without <code>this</code> ?</p>

<p>If the argument variable name is same as class property name and i am using that property inside the method. What does java interpret that "class property" or "the argument variable" ?</p>

<p>Without <code>this</code>:</p>

<pre><code> public User(int userId){
    userId = userId;

 }
</code></pre>

<p>With <code>this</code>:</p>

<pre><code> public User(int userId){
    this.userId = userId;

 }


 public void PrintUserId(){
    System.out.println(this.userId);
}

 User firstUser = new User(123);
 firstUser.PrintUserId(); 
</code></pre>

<p>// 0 without this</p>

<p>//123 with this</p>
