//取整,返回小于目标函数的最大整数,如下将会返回-2 Math.floor(-1.8); //取整,返回发育目标数的最小整数 Math.ceil() //四舍五入取整 Math.round() //计算平方根 Math.sqrt() //计算立方根 Math.cbrt() //返回欧拉数e的n次幂 Math.exp(3); //计算乘方,下面是计算3的2次方 Math.pow(3,2); //计算自然对数 Math.log(); //计算绝对值 Math.abs(); //计算最大值 Math.max(2.3,4.5); //计算最小值 Math.min(,); //返回一个伪随机数,该数大于等于0.0并且小于1.0 Math.random
import java.util.Arrays;
import java.util.Random;
public class RandomTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Random rand = new Random();
System.out.println("随机布尔数" + rand.nextBoolean());
byte[] buffer = new byte[16];
rand.nextBytes(buffer);
//生产一个含有16个数组元素的随机数数组
System.out.println(Arrays.toString(buffer));
System.out.println("rand.nextDouble()" + rand.nextDouble());
System.out.println("Float浮点数" + rand.nextFloat());
System.out.println("rand.nextGaussian" + rand.nextGaussian());
System.out.println("" + rand.nextInt());
//生产一个0~32之间的随机整数
System.out.println("rand.nextInt(32)" + rand.nextInt(32));
System.out.println("rand.nextLong" + rand.nextLong());
}
}
ThreadLocalRandom trand= ThreadLocalRandom.current(); int val = rand.nextInt(4,64);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有