Here you can find the source of multiply(int[][] mat1, int[][] mat2)
public static int[][] multiply(int[][] mat1, int[][] mat2)
//package com.java2s; //License from project: Open Source License public class Main { public static int[][] multiply(int[][] mat1, int[][] mat2) { int sizeY = mat1.length; int sizeX = mat1[0].length; int tmp = 0; int[][] result = new int[sizeX][sizeY]; for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeX; j++) { tmp = 0;// ww w . j a v a 2s . c o m for (int k = 0; k < sizeY; k++) { tmp += mat1[k][j] * mat2[i][k]; } result[i][j] = tmp; } } return result; } }