class Demo
{
public static void main(String[] args)
{
int[] sale = new int {32,32,153,123,22,31,7,2,2};
System.out.println("********************");
System.out.println(sale[4]);
System.out.println("----------------------------");
int[][] sales = {{10,9,8},{16,23,32},{67,112,223},{123,2,0}};
//第一季度的销售额;
int sum1=0 ;
for(int y = 0; y <sales[0].length; y++)
{
sum1 += sales[0][y];
}
System.out.println("第一季度销售额为:"+sum1);
//-------------------
int sum = 0;
for (int x = 0; x < sales.length ;x++ )
{
for (int y = 0;y < sales[x].length ; y++)
{
sum += sales[x][y];
}
}
System.out.println("年度销售额:"+sum);
}//main方法结束
public static void printArray(int [] arr)//遍历数组的方法
{
for(int x = 0; x < arr.length; x++){
System.out.println(arr[x]);
}
}
} |