当前位置:网站首页>Math.random()的用法
Math.random()的用法
2022-07-20 20:54:00 【黑白不纯】
Math.random()
函数返回一个浮点数, 伪随机数在范围从0 到小于1,也就是说,从 0(包括 0)往上,但是不包括 1(排除 1)。
public class Text2 {
public static void main(String[] args) {
System.out.println(Math.random());
}
}
Math.random()
取[num1,num2)之间int类型随机数的格式为 :
int random= (int)(Math.random()*(num2-num1)+num1)
例:取[10,49)之间数据
public class Text2 {
public static void main(String[] args) {
int random= (int)(Math.random()*(49-10)+10);
System.out.println(random);
}
}
边栏推荐
- [CVA valuation training camp] read the annual reports of listed companies_ Lesson 2
- The first blog experts to obtain entity certificates on the list
- [binary tree] maximum product of split binary tree
- [quick start tutorial 3] crazy shell · open source formation UAV - development environment construction
- TCP sliding window explanation (very practical)
- Internship: several steps to get familiar with the project code
- Opportunities and challenges coexist for financial enterprises to go to sea in emerging markets, advance AI ensures its safety and compliance development
- How many bytes do double, float and long occupy?
- 【C 练习】求一个数最少需要多少步可变为斐波那契数
- 【CVA估值训练营】读懂上市公司年报_第二讲
猜你喜欢
From fail to pass, what did DDR debugging go through?
发票自动处理——摆脱纸张和数据输入的束缚,自动化工作流程和异常处理,大幅缩短审核准备时间
光栅化全面解析
asp.net -编辑超链接事件
C语言详解系列——goto语句的讲解和循环语句的简单练习题
Arithmetic operator 2 (Gretel software - Jiuye practical training)
DAMA-总结(数据管理的总结)
第二章第十一节:元组
Expose the insider of Apache Doris data Lake analysis technology? Rare earth Developers Conference free registration!
mysql数据900W+从17s到300ms是怎么做到的?sql优化的魅力(荣耀典藏版)
随机推荐
Kingbasees database administrator's Guide -- 15.2 Manage sequence
很多人认为元宇宙的发展逻辑和互联网是一致的,但笔者并不觉得
SQL Server 查询语法汇总
Audience analysis and uninstall analysis have been comprehensively upgraded, and HMS core analysis service version 6.6.0 has been updated
Skillfully using roaringbitmap to deal with the memory diff problem of massive data
Arithmetic operator 2 (Gretel software - Jiuye practical training)
Automatic invoice processing - get rid of the shackles of paper and data input, automate workflow and exception handling, and significantly shorten the audit preparation time
金仓数据库KingbaseES数据库管理员指南--15.4. 视图、同义词和序列的数据字典视图
上榜 首批获得实体证书的博客专家
带你认识一下数仓的分区自动管理
Multiplier technology cloud management and control platform adapts to Alibaba cloud polardb, and jointly promotes the prosperity of cloud native database ecosystem
从表面看,元宇宙可能将从根本上改变人们的生产和生活方式
虚拟机双网卡配置
C语言详解系列——goto语句的讲解和循环语句的简单练习题
[binary tree] maximum product of split binary tree
【快速上手教程3】疯壳·开源编队无人机-开发环境搭建
浅聊一下 布隆过滤器
DAMA-第七章(数据安全)
金仓数据库KingbaseES数据库管理员指南--15.2. 管理序列
PLC的通信模式