10个随机数求出最大者
package com.swift; import java.util.Random; public class RandomMax { public static void main(String[] args) { int max=0; Random random=new Random(); for(int i=0;i<10;i++) { int ran=random.nextInt(100)+1;//Random类生成0~99的随机数 if(max<ran) { max=ran; } System.out.println(ran); } System.out.println("The most max number is:"+max); } }
Never waste time any more, Never old man be a yong man