Q: Error when calling method in Java I have a class with 3 methods that essentially does some basic stuff with arrays of arrays in Java, although when trying to call these methods in my main i get an error.. Could anyone tell me what the problem is... Im sure its some stupid basic mistake :(
class Matrix {
    double[][] m = { {2,4,31,31}, 
                  {3,3,21,41},
                  {1,2,10,20},
                  {3,2,20,30} };

    public static void negate(double[][] m){
        int r = m.length;
        int c = m[r].length;
        double[][] n = new double[c][r];
        for(int i = 0; i < n.length; ++i) {
            for(int j = 0; j < n[i].length; ++j) {
                n[i][j] = (m[i][j])*-1;
            }
        }

    }

    public static void transposeMatrix(double[][] m){
        int r = m.length;
        int c = m[r].length;
        double[][] t = new double[c][r];
        for(int i = 0; i < r; ++i){
            for(int j = 0; j < c; ++j){
                t[j][i] = m[i][j];
            }
        }

    }

    public void print(double[][] n, double[][] t){
        int r = m.length;
        int c = m[r].length;

        for(int i = 0; i < r; ++i){
            for(int j = 0; j < c; ++j){
            System.out.print(" " + n[i][j]);
            }
            System.out.println("");
            }

        for(int i = 0; i < r; ++i){
            for(int j = 0; j < c; ++j){
            System.out.print(" " + t[i][j]);
            }
            System.out.println("");
            }
    }
}

now this is the main i had..
public class testMatrix {
    public static void main(String[] args){

        Matrix.negate(m);
    }

}

thanks in advance for any input!
this is the error...
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    m cannot be resolved to a variable

    at testMatrix.main(testMatrix.java:5)


A: 
Exception in thread "main" java.lang.Error: Unresolved compilation
  problem: 
      m cannot be resolved to a variable
      at testMatrix.main(testMatrix.java:5)

By looking at your error its pretty obvious, You need an instance of the Matrix class to access its instance variable
 Matrix.negate(new Matrix().m);

