Question
Public class Location{ private int row, col; public Location( int r, int c ) { row = r; col = c; } public int row()
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started