- 1 在文档 JDK_API7.0.CHM 中,找到Math类中的random()函数
- 2 使用的例子,代码如下:
class RandomDemo{
public static void main(String[] args) {
double a = Math.random();
System.out.println("The value of a is "+a);
}
}
运行结果为:
The value of a is 0.8124022683494829
- 3 注意事项
- 3.1 类的结构的区别
- 3.1.1 java.lang包下的类,是可以直接使用的。比如Math
- 3.2.2 非java.lang包下的类,需要导入才能使用。比如Scanner
- 3.1.1 java.lang包下的类,是可以直接使用的。比如Math
- 3.1 类的结构的区别