定义一个数组 并求数组内值得和
public class Demo3 {
public static void main(String
[] args
) {
int [] sum
= new int[5];
sum
[0] = 1;
sum
[1] = 2;
sum
[2] = 3;
sum
[3] = 4;
sum
[4] = 5;
int sums
= 0;
for (int i
= 0; i
< sum
.length
; i
++){
sums
= sums
+ sum
[i
];
}
System
.out
.println("数组中的和为"+sums
);
}
}
转载请注明原文地址: https://lol.8miu.com/read-1519.html