public static void main(String[] args) { int[][] array = { {10,20,30}, {40,50,60}, {70,80,90}, }; RowColumn(array); SumRow(array); SumColumn(array); String[][] name = { {"Moha", "Ade", "Yahya"}, {"Abdi", "abdirahman", "Xidig"}, }; names(name); } public static void RowColumn(int[][] array) { for(int i =0; i<array.length; i++) { for(int j=0; j<array[i].length; j++) { System.out.print(array[i][j] + " "); } System.out.println(); } } public static void SumRow(int[][] array) { for(int i=0; i<array.length; i++) { int Sum = 0; for(int j=0; j<array[i].length; j++) { Sum = Sum + array[i][j]; } System.out.println("\nSum of Row " + i + ", is = " + Sum ); } } public static void SumColumn(int[][] array) { for(int j=0; j<array[0].length; j++) { int sum = 0; for(int i=0; i<array.length; i++) { sum = sum + array[i][j]; } System.out.println("\nSum of Column " + j + ", is = " + sum); } } public static void names(String[][] name) { for(int j=0; j<name[0].length; j++) { String full_name = " "; for(int i=0; i<name.length; i++) { full_name = full_name + name[i][j]; } System.out.println("\nfull names of colum " + j + ", are " + full_name); } } } //OUTPUT: 10 20 30 40 50 60 70 80 90 Sum of Row 0, is = 60 Sum of Row 1, is = 150 Sum of Row 2, is = 240 Sum of Column 0, is = 120 Sum of Column 1, is = 150 Sum of Column 2, is = 180 full names of colum 0, are MohaAbdi full names of colum 1, are Adeabdirahman full names of colum 2, are YahyaXidig
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter