2016-1-8作业

 1 int myarray[] = new int[]{44,22,301,54,5,88,7,48,9,10};
 2         
 3         //遍历并输出所有的数
 4         for(int x :myarray)
 5         {
 6             System.out.print(x+" ");
 7         }
 8         System.out.println();
 9         
10         //利用foreach来写输出数组中最大的数
11         
12                 int Max = myarray[0];
13                 
14                 for(int x:myarray)
15                 {
16                     if(Max>=x)
17                     {
18                     }
19                     else
20                     {
21                         Max = x;
22                     }
23                 }
24                 System.out.println("这个数组中最大的值是:"+Max);

运行结果:

原文地址:https://www.cnblogs.com/zhengfengyun/p/5114682.html