Random随机数
package test; import java.util.Random; public class java01 { public static void main(String[] args) { //1.创建Random对象 Random rd = new Random(); int x = rd.nextInt(5);//取值范围[0,5) int y = rd.nextInt(5)+2;//取值范围[2,5) System.out.println(x); System.out.println(y); } }