This is the problem, how to know the index of a matrix using a method in Java?
package myMethods;
public class MyMath {
public static int[] indexOfMatrix(int[][] M,int toFind) {
int index[]= {-1,-1};
for(int rows=0; rows<M.length; rows++) {
for(int columns=0; columns<M[rows].length; columns++) {
if(toFind==M[rows][columns]) {
index[0]=rows;
index[1]=columns;
return index;
}
}
}
return index;
}
public static void main(String[] args) {
int[][] d={{3,7,8},{4,5,6},{2,1,0}};
System.out.println(indexOfMatrix(d,4));
}
}
I expect a number to be the output not "[I@15db9742"