I created a 2D array(called names) to store string values. Initially, I assign all the elements in the array to blanks.
I do this by having a variable that stores the maximum rows and iterate through the array filling its elements with blanks.
public class Untitled
{
    public static void main(String[] args) 
    {
        int maxRows = 10 ;
        String names[][] = new String[maxRows][2] ;
        int y = 0 ;
        while(y <= maxRows)
        {
            int x = 0 ;
            while (index < 2)
            {
                names[y][x] = " " ;
                index++ ;               
            }
            counter++ ;
        }       
    }
}
However, once the code is compiled and run, I get an error saying "Exception in thread "main" java.lang.ArrayOutOfBoundsException : 10"
 
    