title: How are chained assignments in java defined? Is there a difference between value and reference types?
body: <p>How are chained assignments in java defined, considering following points:</p>
  
  <ul>
  <li>Is there a difference between chained assignment and chained declaration?</li>
  <li>Is there a way for reference types to repeat the statement instead of passing the reference?</li>
  </ul>
  
  <p>E.g. </p>
  
  <pre><code>Integer a, b = new Integer(4);
  </code></pre>
  
  <p>In <a href="http://docs.oracle.com/javase/specs/jls/se5.0/html/expressions.html" rel="nofollow">JLS 15.26 Assignment Operators</a> it says</p>
  
  <blockquote>
    <p>At run time, the result of the assignment expression is the value of the variable after the assignment has occurred. The result of an assignment expression is not itself a variable.</p>
  </blockquote>
  
  <p>So <code>a == b</code> should be true.</p>
  
  <p>Is there a way to achieve</p>
  
  <pre><code>Integer a = new Integer(4)
  Integer b = new Integer(4)
  </code></pre>
  
  <p>in one line so that
  <code>a != b</code>, since <code>a</code> and <code>b</code> are different objects.</p>
  
  <p><strong>Additional Info</strong></p>
  
  <p>The question is already answered, but I felt it was not clear enough, so here some code
  to clarify it.</p>
  
  <pre><code>Integer a = null, b = null, c = null;
  System.out.println(a + " " + b + " " + c); // null null null
  a = b = c = new Integer(5); // &lt;-- chained assignment
  System.out.println(a + " " + b + " " + c); // 5 5 5
  System.out.println(a.equals(b)); // true
  System.out.println(b.equals(c)); // true
  System.out.println(a == b); // true
  System.out.println(b == c); // true
  </code></pre>