public class GenerateRandomNextInt { public static void main(String[] args) { int leftLimit = 2; int rightLimit = 11; Random random = new Random(); Runnable r = () -> { int generatedInteger = leftLimit + random.nextInt(rightLimit - leftLimit + 1); System.out.println(generatedInteger); }; for (int i = 1; i < 10; i++) { new Thread(r).start(); } } }
生成指定范围的随机数
猜你喜欢
转载自www.cnblogs.com/turbozhang/p/12699038.html
今日推荐
周排行