random 随机数

示例说明:

 

 1 import java.util.Random;
 2 public class c
 3 {
 4     public static void main(String[] args)
 5     {
 6         Random ra  = new Random();
 7         for(int i = 1; i <= 10; i++)
 8         {
 9             int num = ra.nextInt(10); //其实就是:【0-10)  包含0,不包含10的, 十个数字的里的随机数
10             System.out.println(num);
11         }
12     }
13 }

 

posted @ 2025-09-26 15:09  字节虫  阅读(12)  评论(0)    收藏  举报