Bitwise operations in Java give different value with similar code? : <p>Short question. I am quite new to doing bit/bytewise operations in Java, but I noticed something strange. </p>

<p>The code below gives as output:</p>

<pre><code>2
0
</code></pre>

<p>code: </p>

<pre><code>String[] nodes = new String[3];
boolean in;
int index = 0;
int hash = "hi".hashCode();
in = (nodes[(index = nodes.length - 1) &amp; hash]) != null;
System.out.println(index);
index = (nodes.length - 1) &amp; hash;
System.out.println(index);
</code></pre>

<p>Why is it, that index has a different value even though the operation to assign a value to index is identical in the 5th and 7th line of code?</p>

<p>Like I said, I'm new to bitwise/bytewise operations so I'm probably missing some background information.</p>
