Making different operations with matrices in Java.