Creating a 2D array from a txt file I was told to create a 2D array from a txt file that had the "carModel, carColor" followed by a new line. The 2D array is 8x8 and for each time a certain carmore and carcolor appear, their respective [x][y] coordinate that represents their count goes up by 1.

So far, I have read the file, created a 2D array from the file, and have created an output with the 2D array and every slot filled with zero, but the only way I can seem to figure out to update each model,color count is if I manually make 64 if-statements to check if they appear in the list n+ times. Surely there has to be another way?

For example, When my scanner reads through the list, I need it to check if the list repeats the carmodel, carcolor and if so, update the count of that carmake and color.

This is the code I have thus far:

public static void main (String [] args) throws Exception
{
    String [][] cars = new String [8][8]; 
    ArrayList &lt;String&gt; colors = new ArrayList&lt;&gt;();
    colors.add("BLUE  ");
    colors.add("BLACK ");
    colors.add("BROWN ");
    colors.add("GREEN ");
    colors.add("RED   ");
    colors.add("SILVER");
    colors.add("WHITE ");
    Collections.sort(colors);
    ArrayList &lt;String&gt; models = new ArrayList&lt;&gt;();
    models.add("Escape  ");
    models.add("Explorer");
    models.add("F150    ");
    models.add("F250    ");
    models.add("Flex    ");
    models.add("Mustang ");
    models.add("Taurus  ");
    Collections.sort(models);
    cars [0][0] = "_____  ";
    for (int a = 1; a &lt; cars.length; a++)
    {
        cars[0][a] = (models.get(a-1)) + " ";
    }
    for (int b = 1; b &lt; cars.length; b++)
    {
        cars[b][0] = (colors.get(b-1)) + " ";
    }
    for (int fir = 1; fir &lt; cars.length; fir++)
    {
        for (int sec = 1; sec &lt; cars[1].length; sec++)
        {
            if (cars[fir][sec] == null)
            {
                cars[fir][sec] = "0        ";
            }
        }
    }       
    for (int first = 0; first &lt; cars.length; first++)
    {
        for (int second = 0; second &lt; cars[first].length; second++)
        {
            System.out.print(cars[first][second]);
        }
        System.out.println();
    }        
    File file = new File ("C:\\Users\\delta\\Documents\\NetBeansProjects\\SchoolWork\\cars.txt");
    Scanner sc = new Scanner(file);
    String ab = sc.nextLine();
        while (ab != null)
        {
            String [] nums = sc.nextLine().split(" ");
            for (int i = 0; i &lt; nums.length;i++)
            {                  
               System.out.println(nums[i]);                    
            }               
        }        
}


The output is supposed to look something like this:
Consider using Arrays.asList("", ...) to create lists in-line.
Why are colors and models Lists while cars is an Array? It seems like you can use Arrays for all of this.
Consider using "anonymous arrays" (terrible name) to create Arrays in-line. 
Consider first building the "true" data structure as int[][] car_counts = new int[7][7], a zero-indexed 2D array of counts. Then treat the task of printing it as shown in the image as a separate problem. 
Your while loop at the end appears to be incorrectly indented.
That while loop should be building a data-structure that you can neatly read the file into: a list of pairs of strings. (or even a list of pairs of ints, representing indexes into models and colors.)