int max=Integer.MIN_VALUE;
System.out.print("产生的
随机数:");
for(int i =0 ;i<10;i++){
int random = new Random().nextInt(100);
System.out.print(random+",");
if(random>max){
max = random;
}
}
System.out.println("\n最大值:"+max);
打印结果如下:
产生的随机数:32,43,82,99,86,31,85,67,33,81,
最大值:99