int[][] table = new int[3][3]; int sign = 1; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { table[i][j] = sign * (2*i+2*j+1); } sign *= -1; } System.out.println(table[1][2]*table[2][1]);