title: Why is assert used in the Integer.valueOf method of the Integer class?
body: <p>I was digging into how the <code>Integer</code> class actually uses cached objects, and I found the below code in the <code>Integer.valueOf</code> method:</p>
  
  <pre><code>public static Integer valueOf(int i) {
      assert IntegerCache.high &gt;= 127;
      if (i &gt;= IntegerCache.low &amp;&amp; i &lt;= IntegerCache.high)
          return IntegerCache.cache[i + (-IntegerCache.low)];
      return new Integer(i);
  }
  </code></pre>
  
  <p>My question is:</p>
  
  <ul>
  <li>what is the use of <code>assert IntegerCache.high &gt;= 127;</code> I read that
  <a href="http://www.javatpoint.com/assertion-in-java">assert provides an effective way to detect and correct programming
  errors</a>. But this is runtime code so why would someone use assert?</li>
  <li>And when will it throw <code>AssertionError</code> in this scenario?</li>
  </ul>