?? testrandom.java
字號:
import java.util.*;
/**
* Description:
* <br/>Copyright (C), 2005-2008, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class TestRandom
{
public static void main(String[] args)
{
Random rand = new Random();
System.out.println("rand.nextBoolean():" + rand.nextBoolean());
byte[] buffer = new byte[16];
rand.nextBytes(buffer);
System.out.println(Arrays.toString(buffer));
//生成0.0~1.0之間的偽隨機double數(shù)
System.out.println("rand.nextDouble():" + rand.nextDouble());
//生成0.0~1.0之間的偽隨機float數(shù)
System.out.println("rand.nextFloat():" + rand.nextFloat());
//生成平均值是 0.0,標準差是 1.0的偽高斯數(shù)
System.out.println("rand.nextGaussian():" + rand.nextGaussian());
//生成一個處于long整數(shù)取值范圍的偽隨機整數(shù)
System.out.println("rand.nextInt():" + rand.nextInt());
//生成0~26之間的偽隨機整數(shù)
System.out.println("rand.nextInt(26):" + rand.nextInt(26));
//生成一個處于long整數(shù)取值范圍的偽隨機整數(shù)
System.out.println("rand.nextLong():" + rand.nextLong());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -