使用Math类,生成5个1~10之间的随机整数, 并将结果打印到控制台. 参考代码 public class MathDemo01 { public static void main(String[] args) { //1. 定义for循环, 用来获取5个随机数. int num; for (int i = 1; i <= 5; i++) { //2.获取随机数, 并打印 num = (int)(Math.random()*10...
list = new ArrayList<Integer>(); //定义100个随机数 集合 for(int i = 0; i < 100;) { //产生100个3位数 的随机不重复数字 if(check(rand.nextInt(899) + 100,list)) { i++; } //用set时 Set<Integer> set = new HashSet<Integer>(); while(set.size() < 100) { set.add(r...