博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nextfloat_Java Random nextFloat()方法与示例
阅读量:2534 次
发布时间:2019-05-11

本文共 1601 字,大约阅读时间需要 5 分钟。

nextfloat

随机类nextFloat()方法 (Random Class nextFloat() method)

  • nextFloat() method is available in java.util package.

    nextFloat()方法在java.util包中可用。

  • nextFloat() method is used to generate the next pseudo-random float value between the range 0.0 and 1.0 from this Random Value Generator.

    nextFloat()方法用于从该随机值生成器生成介于0.0和1.0之间的下一个伪随机浮点值。

  • nextFloat() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    nextFloat()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • nextFloat() method does not throw an exception at the time of returning float.

    返回float时, nextFloat()方法不会引发异常。

Syntax:

句法:

public float nextFloat();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is float, it returns next pseudo-random distributed float value between the given range from this Random Generator.

方法的返回类型为float ,它从该Random Generator返回给定范围之间的下一个伪随机分布float值。

Example:

例:

// Java program to demonstrate the example // of float nextFloat() method of // Randomimport java.util.*;public class NextFloatOfRandom {
public static void main(String args[]) {
// Instantiates Random object Random ran = new Random(); // By using nextFloat() method is // to return float pseudo-random // value between 0.0 and 1.0 by // using Random Value Generator float val = ran.nextFloat(); // Display System.out.println("ran.nextFloat(): " + val); }}

Output

输出量

RUN 1:ran.nextFloat(): 0.89347947RUN 2:ran.nextFloat(): 0.48533785RUN 3:ran.nextFloat(): 0.2989604

翻译自:

nextfloat

转载地址:http://lxtzd.baihongyu.com/

你可能感兴趣的文章
P3384 【模板】树链剖分
查看>>
Thrift源码分析(二)-- 协议和编解码
查看>>
考勤系统之计算工作小时数
查看>>
4.1 分解条件式
查看>>
Equivalent Strings
查看>>
flume handler
查看>>
收藏其他博客园主写的代码,学习加自用。先表示感谢!!!
查看>>
H5 表单标签
查看>>
su 与 su - 区别
查看>>
C语言编程-9_4 字符统计
查看>>
在webconfig中写好连接后,在程序中如何调用?
查看>>
限制用户不能删除SharePoint列表中的条目(项目)
查看>>
【Linux网络编程】使用GDB调试程序
查看>>
feign调用spring clound eureka 注册中心服务
查看>>
ZT:Linux上安装JDK,最准确
查看>>
LimeJS指南3
查看>>
关于C++ const成员的一些细节
查看>>
《代码大全》学习摘要(五)软件构建中的设计(下)
查看>>
C#检测驱动是否安装的问题
查看>>
web-4. 装饰页面的图像
查看>>