/////// TestMatrix.java /////// package matrix; class TestMatrix { public static void main(String[] args) throws ClassNotFoundException { double[][] a = { {1.0,-2.0,1.5}, {1.0,2.4,3.1}}; double[][] b = { {9.0,0.7},{-2.0,30.5},{-9.0,4.0}}; double[][] c = { {9.0,0.7},{-2.0,30.5}}; Matrix m1 = new Matrix(a); Matrix m2 = new Matrix(b); Matrix m3 = new Matrix(c); try { Matrix prod = m1.times(m2); System.out.println(prod); prod = m1.times(m3); } catch(MatrixException e) { handle(e); System.exit(1); } } private static void handle(MatrixException e) throws ClassNotFoundException { if ( e instanceof SingularException ) { System.err.println("S:" + e.getMessage()); } else if ( e instanceof IncompatibleDimException ) { System.err.println("D:"+ e.getMessage()); } else if ( e instanceof InvalidIndexException ) { System.err.println("I:"+ e.getMessage()); } } }