I have a HashMap with following settings:
HashMap hm = new HashMap<String, Matrix>();
Observe the next part:
public void init() {
hm.put("a", new Matrix(3, new int[][] {{1,2,3},{4,5,6},{7,8,9}}));
}
And the Matrix.java file looks like this:
import java.util.*;
/**
* @author Mark Lonquist
* @version 1.0
*/
public class Matrix {
public Matrix(int matrixSize, int[][] numbers)
{
matrix = new int[matrixSize][matrixSize];
matrixNumbers = numbers;
matrix = matrixNumbers;
}
public int[][] matrixNumbers(Matrix matrix)
{
return (matrixNumbers);
}
public int size()
{
return matrix.length;
}
public int sizeInside()
{
return matrix[0].length;
}
private int matrix[][];
private int matrixNumbers[][];
}
It gives me the following error when running this "main":
public static void main(String[] args)
{
Program program = new Program();
program.init();
}
run:
Exception in thread "main" java.lang.NullPointerException
at Program.init(Program.java:109)
at Program.main(Program.java:116)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Why is this??
Edited by qutazs, 05 December 2011 - 09:44 AM.


Sign In
Create Account


Back to top









