Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class App7 {
- public static void main(String[] args) {
- int[][] matrix ={
- {1,2,3},
- {4,5,6},
- {7,8,9}
- };
- int sum = 0;
- for (int row = 0; row < matrix.length; row++) {
- int[] currentRow = matrix[row];
- for (int cols = 0; cols < currentRow.length; cols++) {
- sum+=currentRow[cols];
- }
- }
- System.out.println("MatrixSum: "+ sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement