public class 取得数组总和 { public static void main(String[] args) { int[] data= {12,43,8,9,1,46,32,23,65,78,1,1}; double s=0; for(int x=0;x<data.length;x++) { s=s+data[x]; } System.out.println(s); } }
public class 取得数组总和平均值 { public static void main(String[] args) { int[] data= {12,43,8,9,1,46,32,23,65,78,1,1}; double s=0; for(int x=0;x<data.length;x++) { s=s+data[x]; } System.out.println(s/data.length); } }