生成四位随机数

public class Test {
    public static void main(String[] args) {
      
        String s="";
        Random random = new Random();
        System.out.println(random.nextInt(9));
        for (int i = 0; i < 4; i++) {
            s+=random.nextInt(9);
        }
        System.out.println(s);
    
    System.out.println(random.nextInt(9999));
} }

生成四位随机数

 

posted on 2022-02-15 11:59  菊_酒  阅读(241)  评论(0)    收藏  举报