import java.util.Random;
public class test {
public static void main(String[] args) {
//随机数Random的使用
Random r = new Random();
//调用方法就可以产生随机数了
//nextInt() +-21亿之间的随机数
// int num = r.nextInt();
//nextInt(n) [0~n)之间的随机数
int num = r.nextInt(10); //0~9
System.out.println(num);
}
}
Java中Random类简单用法
猜你喜欢
转载自blog.csdn.net/qq_44458489/article/details/104844095
今日推荐
周排行