把三个数放到一个数组里,然后随机取下标就行了
int[] all = {432,34,3453};
int rand = new Random().nextInt(3);
Thread.sleep(all[rand]);
import java.util.Random;
public class R {
public static void main(String[] args) {
int[] a={1000,3000,5000};
int r=new Random().nextInt(3);
try {
Thread.sleep(a[r]);
System.out.print(a[r]);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
在我的机子上测试没出错,不知道你那行不
不会没用IDE吧?不导类不自动报错吗?
。。。。。你把类导进去啊!