title: Java Integer pool. Why?
body: <p>I've read everywhere that when you define an Integer between -128 to 127 in Java, instead of creating a new object it returns an object already created.</p>
  
  <p>I don't see any point of doing this other than letting newbie programmers compare Integer objects with <code>==</code> to see if they are the same number, but I think this is bad because sure they think that they can compare any Integer with <code>==</code>, and also is teaching a bad practice in any programming language: comparing the content of two 'different' objects with <code>==</code>.</p>
  
  <p>Is there any other reason on why this is done? Or is it just a bad decision when designing the language (In my point of view) like optional semicolon in JavaScript?</p>
  
  <p>EDIT: I see here that they explain the behaviour: <a href="https://stackoverflow.com/questions/13098143/why-does-the-behavior-of-the-integer-constant-pool-change-at-127">Why does the behavior of the Integer constant pool change at 127?</a></p>
  
  <p>I'm asking why they designed it to have this behaviour, and not why is this behaviour happening.</p>