Get specific element from array in Java
问题 Basically I am trying to return an element from an 2d array in java. I have created a separate Matrix class and inside the class I want to write a get_element method which would take as input the coordinates of the element I want from the matrix and the matrix itself, however I am not sure how to do this. public static double get_element(Matrix A, double m , double n) { for(int i=0;i<A.rows;i++) for(int j=0;j<A.cols;j++) return A.data[m][n]; } This is how my code look right now. And I get an