http://blog.csdn.net/huangbiao86/article/details/6433964 java中Math.random()与java.util.random()的区别

public class Random1 {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        for(int i=10;i<30;i++){
            System.out.println((int)(1+Math.random()*10));
            //1-10的随机数
        }
    }

}
import java.util.Random;

public class Random2 {
    public static void main(String[] args) {
    Random rr = new Random();
    int number = rr.nextInt(10); //输出1-10随机数
    
        System.out.println(1+number);//不1+则输出0-10随机数
    
    
}

}

 http://blog.sina.com.cn/s/blog_4f925fc30100uvur.html  更详细的Random

http://blog.csdn.net/gao454917848/article/details/38557101  整洁性的Random解释

 

相关文章:

  • 2022-02-10
  • 2022-02-10
  • 2022-02-10
  • 2022-02-10
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2022-01-01
  • 2021-05-25
  • 2021-05-17
  • 2022-02-10
  • 2021-12-17
  • 2022-01-02
相关资源
相似解决方案