Random r = new Random(); int num1 = r.nextInt(9)//0~8之间的随机数; int num2 = r.nextInt(9) + 1;//1~9之间的随机数;
需要声明import java.util Random;