补充一下:
import java.util.*;
public class  Conversion
{
public static void main(String[] args) throws IOException
{
Random ri=new Random(100);
int i;
i=ri.nextInt();
System.out.print(i+"     ");
}
}下面是我运行8次得到的结果:-1193959466  -1193959466     -1193959466     -1193959466     -1193959466     -1193959466     -1193959466     -1193959466     

解决方案 »

  1.   

    Random类就是这样的,看api文档就可以知道,这个Random也只是个伪的,如果速度不考虑,用SecureRandom 或者简单一点,用Math的random()
      

  2.   

    如果你想产生0-100之间的随机数,应该用Math.random()*100
      

  3.   

    Random ri=new Random(100);这里的是seed的变化大小,是内部用来产生随机数的变量。
      

  4.   

    如果你想产生0-100之间的随机数,应该用Math.random()*100
      

  5.   

    java.util.Random.java 文件的注释写的很清楚:
    ————————————————————————————
    If two instances of <code>Random</code> are created with the same 
     * seed, and the same sequence of method calls is made for each, they 
     * will generate and return identical sequences of numbers.
    ————————————————————————————
      

  6.   


    public class password
    {

    static void main(String args[])
    {
     int int1
     Random test=new Random();
         for (int i=0;i<10;i++)
         {
         int1=Math.abs(test.nextInt())+100;     System.out.print(int1);     }
    }


    }
      

  7.   

    Random不是真正的Random了,如果你看过Data Structures with C++
    就知道了,那里就叫你写了一个Random类,他使用一个seed通过一顿
    胡乱暴算,得出一个数,返回。
    通常是你可以用系统时间等易变的变量做seed构造Random,
    或者用Math的
      

  8.   

    Random(int)是伪随机数啊。
    这个和所有语言是一样的。======================
      

  9.   

    算是我的hello world for java吧
    还好结果是对的  public static void main(String[] args) {
        JRandom_Test JRandom_Test1 = new JRandom_Test();    double douRandom=0;
        int intRandom=0;
        System.out.println("Random Test");
        for(int i=0;i<100;i++){
             if(i%5==0){
                 System.out.print("\r\n"+(new Integer(i/5)).toString()+"\t");
             }
             douRandom=java.lang.Math.random()*100;
             intRandom=(new Double(douRandom)).intValue();
             System.out.print(intRandom);
             System.out.print("\t");    }
      

  10.   

    new Random().nextInt(500)
    ================================================================
    ★★