0
点赞
收藏
分享

微信扫一扫

Random类


// Random类
package ch22;
import java.util.*;
public class RandomDemo {
public static void main(String[] args) {
// 构造 Random 类对象
Random random = new Random();
// 任意随机整数
int ri = random.nextInt();
// 0<=ri2<10 之间的整数
int ri2 = random.nextInt(10);
// 任意浮点数
double rd = random.nextDouble();
System.out.println("ri="+ri);
System.out.println("ri2="+ri2);
System.out.println("rd="+rd);
}
}

Random类_浮点数


举报

相关推荐

0 条评论