[JAVA]生成随机数

 

public class GetRandomInit {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Random random = new Random();//默认以当前时间为随机数种子
        for(int i=0;i<5;++i){
            System.out.println(random.nextInt(100));//生成100以内的随机数
        }
    }
}

 

posted on 2018-09-01 18:40  郑晓龙  阅读(86)  评论(0编辑  收藏  举报

导航