title: Java - array's index out of bounds when its not?
body: <p>I have a problem in the code below:</p>
  
  <pre><code>/* package whatever; // don't place package name! */
  
  import java.util.*;
  import java.lang.*;
  import java.io.*;
  
  /* Name of the class has to be "Main" only if the class is public. */
  class Ideone {
      public static void main (String[] args) throws java.lang.Exception {
          int[] map = new int[100 * 100];
          System.out.println("Works : " + map[10 * 100 + 5]);
          System.out.println("Works? : " + map[99 * 100 + 99]);
          System.out.println("Works?! : " + map[20 * 100 + 100]);
          //System.out.println("And this?? : " + map[99 * 100 + 100]);
      }
  }
  </code></pre>
  
  <p>As you can see the last line (the comment) doesn't work; it throws an <code>ArrayIndexOutOfBoundsException</code>.</p>
  
  <p>But I dont get it; it should be in the array's bounds. The array's size is <code>100*100</code> so <code>99 * 100 + 100 = 100*100</code> so index <code>100*100</code> is in the array.</p>
  
  <p>I've already fixed the problem; I would just like to know why I get an exception on the above line.</p>
  
  <p>Link to code: <a href="http://ideone.com/ydgU9s" rel="nofollow">http://ideone.com/ydgU9s</a></p>