//Random是系统中已经存在的类import java.util.*;public class random{
static Random Rand = new Random();
public static void main(String[] args){
int i,j;
for(i=1;i<=100;i++){
j = Rand.nextInt(500);
System.out.print(j +"\t");
}
}
}
static Random Rand = new Random();
public static void main(String[] args){
int i,j;
for(i=1;i<=100;i++){
j = Rand.nextInt(500);
System.out.print(j +"\t");
}
}
}
static Random Rand = new Random();
public static void main(String[] args){
int i,j;
for(i=1;i<=100;i++){
j = Rand.nextInt(500);
System.out.print(j +"\t");
}
}
}
系统提示是:E:\carson\java\MyJava\MyTest\random.java:8: cannot resolve symbol
symbol : method nextInt (int)
location: class Random
j = Rand.nextInt(500);
static Random Rand = new Random();
public static void main(String[] args){
int i,j;
for(i=1;i<=100;i++){
j = Rand.nextInt(500);
System.out.print(j +"\t");
}
}
}
这个是不会错的,记得不要把test与你原来的那个Random放在一个目录下,会被认为一个包,然后里面的Random会调用你自己的那个Random