public class T02 { public static void main(String[] args) { int[][]arr=new int[][]{{1,2,3,4,5},{1,2,3,5},{8,9,7}}; int sum=0; for(int i=0;i< arr.length;i++){ for(int j=0;j<arr[i].length;j++){ sum=arr[i][j]+sum; } } System.out.println("sum="+sum); } } //和为50
The above is the detailed content of How to implement summation of array elements in Java. For more information, please follow other related articles on the PHP Chinese website!