import java.util.Random;public class CompType { public static void main(String[] args) { Random nn = new Random(); for(int m = 0;m < 10; m++) { System.out.println(nn.nextInt()%100); } } }
util得Random和时间有关的,所以很短的时间里取是一样的。 用java.lang.Math 中的 static double random() Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
{
public static void main(String[] args)
{
Random nn = new Random();
for(int m = 0;m < 10; m++)
{
System.out.println(nn.nextInt()%100);
}
}
}
用java.lang.Math
中的
static double random()
Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.