title: Why do == comparisons with Integer.valueOf(String) give different results for 127 and 128?
body: <p>I have no idea why these lines of code return different values:</p>
  
  <pre><code>System.out.println(Integer.valueOf("127")==Integer.valueOf("127"));
  System.out.println(Integer.valueOf("128")==Integer.valueOf("128"));
  System.out.println(Integer.parseInt("128")==Integer.valueOf("128"));
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>true
  false
  true
  </code></pre>
  
  <p>Why does the first one return <code>true</code> and the second one return <code>false</code>? Is there something different that I don't know between <code>127</code> and <code>128</code>? (Of course I know that <code>127</code> &lt; <code>128</code>.) </p>
  
  <p>Also, why does the third one return <code>true</code>?</p>
  
  <p>I have read the answer <a href="https://stackoverflow.com/questions/508665/difference-between-parseint-and-valueof-in-java">of this question</a>, but I still didn't get how it can return <code>true</code>, and why the code in second line returns <code>false</code>.</p>