title: Java assignment operator execution
body: <p>In Java, I understand that assignment evaluates to the value of the right operand, so statements like <code>x == (y = x)</code> evaluate to <code>true</code>.</p>
  
  <p>This code, however, outputs <code>false</code>.</p>
  
  <pre><code>public static void main(String[]args){
      String x = "hello";
      String y = "goodbye";
      System.out.println(x.equals(x = y));
  }
  </code></pre>
  
  <p>Why is this? In my understanding, it first evaluates <code>(x = y)</code>, which assigns <code>x</code> the value of <code>y</code>, and then returns the value of <code>y</code>. Then <code>x.equals(y)</code> is evaluated, which should be <code>true</code> since <code>x</code> and <code>y</code> should share the same references now, but instead, I get <code>false</code>. </p>
  
  <p><a href="https://i.stack.imgur.com/6YH2a.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6YH2a.png" alt="Screenshot showing the source and that the output is &quot;false&quot;"></a></p>
  
  <p>What is happening here?</p>