Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
What does the following method do?
public boolean test(String[][] arr, String key) { for(int row = 0; row < arr.length; row++) { for(int col = 0; col < arr[0].length; col++) { if (key.equals(arr[row][col])) { return true; } } } return false; }
Returns true if the String key exists anywhere in the 2D array arr
true
key
arr
Returns true only if the String key exists in the first row of the 2D array arr
Returns true only if the String key exists in the first column of the 2D array arr
Returns true only if the String key does not exist anywhere in the 2D array arr
Returns true only if every element in the 2D array arr is equal to key