Public class Location
{
private int row, col;
public Location( int r, int c )
{
row = r;
col = c;
}
public int row()
{
return row;
}
public int col()
{
return col;
}
public String toString()
{
return "(" + row + ", " + col + ")";
}
public boolean equals( Object x )
{
if ( x instanceof Location )
{
Location other = (Location) x;
return other. row == row && other. col == col;
}
return false;
}
}
import java. util. ArrayList;
public class Main
{
public static void main(String[] args)
{
String [][] m1 = { {"o","t","h","e", "r"}, {"t","e","e","t","h"}};
ArrayList locs1 = finde( m1 );
System. out. println( locs1 ); // [(0, 3), (1, 1), (1, 2)]
String [][] m2 = { {"n","o","t"}, {"n","o","w"} };
ArrayList locs2 = finde( m2 );
System. out. println( locs2 ); // []
}
public static ArrayList finde( String [][] a )
{
/* Returns an ArrayList of Locations where the letter e can be found in the 2D array.
You must traverse the String 2D array in row-major order.
Precondition: all of the strings have a length of one.
The array can be any size. */
return null;
}
}
Complete the finde method. It has one parameter, a 2D array of Strings, and returns an ArrayList of Locations where the letter e can be found in the 2D array. You must traverse the String 2D array in row-major order.
Remember to comment your program.