This is cause ArrayIndexOfBoundsException because you are trying to access element [1][2] which does exist. When you declare an array of size n , the valid indices are 0 to n-1, where n >0. The indices begin from 0 and not 1 as in PASCAL.