new Random().nextInt(1000);// 1000之内
int num = (int) (Math.random() * 1000); // 注意不要写成(int)Math.random()*3,这个结果为0,由于先执行了强制转换