package day01; import java.util.Arrays; import java.util.Random; public class MaxOfArray { public static void main(String[] args) { int[] arr = new int[10]; Random ran = new Random(); //随机生成数 for(int i = 0;i<=9;i++) { arr[i] = ran.nextInt(100); } System.out.println("数组中的数" + Arrays.toString(arr)); int max =arr[0]; for(int j=1;j < arr.length;j++) { if(max < arr[j]) { max = arr[j]; } } System.out.println("数组中最大值:"+ max); } }
转载于:https://www.cnblogs.com/kwinwei/p/10372343.html