首页 > 学院 > 开发设计 > 正文

两个随机数实例

2019-11-14 20:53:37
字体:
来源:转载
供稿:网友
两个随机数实例
/*
import java.util.Random;
public class random_1{
    public static void main(String[] args) {
        Random r=new Random();
        int a=r.nextInt();
        System.out.PRint("随机数为:"+a);
    }
}
*/
//以下程序与上程序效果一样
public class random_1{
    public static void main(String[] args) {
        int r=(int)(Math.random()*10);
        System.out.print(r);
    }
}

上一篇:【Java编程思想

下一篇:Expression Language

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表