应该很简单吧?
帮帮 我

解决方案 »

  1.   

    new Random rand = new Random();
    rand.nextLong();
    nextLong
    public long nextLong()
    Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence. The general contract of nextLong is that one long value is pseudorandomly generated and returned. All 264 possible long values are produced with (approximately) equal probability. The method nextLong is implemented by class Random as follows: 
     public long nextLong() {
           return ((long)next(32) << 32) + next(32);
     }Returns:
    the next pseudorandom, uniformly distributed long value from this random number generator's sequence.
      

  2.   

    public static String getNumString(int len) {
      String retVal = "";
      int i = 0;
      while (i < len) {
        retVal += ( (int) (Math.random() * 10)) + "";
        i++;
      }
      return retVal;
    }
    生成一个指定长度的随机数字型的字符串,可能生成0打头的数字,看看能用吗
      

  3.   

    class random 
    {
    public static void main(String[] args) 
    {
    long a;
    for(int i=1;i<10;i++)
    {
    a=Math.round(0+(9-0)*Math.random());
    System.out.println(a);
    }
    }
    }