Java Code for Matrix