I tried searching for the solution to this problem for a while now and couldn't find anything. How do I sum the elements above the secondary diagonal in a matrix (just with loops, nothing fancy) in Java?
This is what I tried:
public static void Page106Ex3$H(int[][] mat) {
int sum = 0;
for (int i = 1; i < mat.length; i++) {
for (int j = i-1; j >= 0; j--) {
sum += mat[i][j];
}
}
System.out.println("Sum: " + sum);
}