Check Neighbors

If a 2D array can represent something physical, like seats in an airplane.
For example, this shows passengers in the first 3 rows of seats in a small jet.

    String[]  seats = {   {"Jones, A" , "Jones, B", "Jones, C", "xxx"} ,
                                 {"Kim, K" , "Smith, S", "ooo", "ooo"} ,
                                 {"ooo" , "ooo", "Arnold, A", "ooo"} ,
                                  // .... more seats here .... //
                            } ;

When passengers check in, they might ask for 2 (or more) seats together.
Write a method that searches for 2 empty seats ("ooo") together
and prints the location if found.

Solution

public void findSeatsTogether(String[] data, int rows, int columns)
{
    for(int r = 0; r < rows; r = r+1)
    {
        for(int c = 0;  c < columns -1; c = c+1)
        {
            if( data[r][c].equals("ooo")  &&   data[r][c+1].equals("ooo") )
            {
                 output("Row = " + r + "   columns = " + c + " , " + (c+1) );
                 return;
            }
        }
    }
    output("Did not find 2 seats together");
}