COMPLETE QUESTION:
What does this method do?
public static int foo(String [][] a)
{
int b = 0;
for (int i = 0; i<a.length; i++)
{
b++;
}
return b;
}
Answer:
Returns the value of b which is the dimension of the array
Step-by-step explanation:
The method foo accepts a multi dimension array and returns the dimension of the array. A complete code implementation and call to the method is given below:
public class TestClass {
public static void main(String[] args) {
String [ ] [ ] arr = {{"gh","hj","fg", "re","tr"},{"","er","df","fgt", "tr"}};
System.out.println(foo(arr));
}
public static int foo(String [ ][ ] a)
{
int b = 0;
for (int i = 0; i<a.length; i++)
{
b++;
}
return b;
}
}
The output from the code snippet is the value of b which is 2