1.8作业


 1 public class WEI {
 2 
 3     public static void main(String[] args) {
 4         // 创建一维数组arr[],并将其遍历输出。
 5         int arr[] = new int[] { 54, 65, 89, 789, 231 };
 6 
 7         // 用foreach语句
 8 
 9         for (int f : arr) {
10             System.out.println("输出为:" + f);
11         }
12 
13         int min = arr[0];
14 
15         for (int a = 0; a < arr.length; a++) {
16             if (min < arr[a]) {
17                 min = arr[a];
18             }
19 
20         }
21 
22         System.out.println("最大的数为" + min);
23     }
24 
25 }

 1 public class WEI {
 2 
 3     public static void main(String[] args) {
 4         //创建一维数组arr[],并将其遍历输出。
 5   int arr []=new int[]{ 54,65,89,789,231};
 6           
 7           //用foreach语句
 8   
 9   for(int f : arr )
10   {
11      System.out.println("输出为:"+f); 
12   }
13           
14           
15           
16           
17           
18           
19     }
20 
21 }

原文地址:https://www.cnblogs.com/crazy-zw/p/5115149.html