要生成在[min,max]之间的随机整数
import java.util.Random; public class RandomTest { public static void main(String[] args) { int min=10; int max=20; Random random = new Random(); //int s = random.nextInt(max)%(max-min+1) + min; int s = random.netInt(max-min+1) + min; System.out.println(s); } }
时间: 2024-10-11 22:22:43