java.text.ChoiceFormat类的nextDouble(double)方法用于获取恰好大于指定的double值的double值。
用法:
public static final double nextDouble(double d)
参数:此方法接受双精度值d作为参数,为其返回下一个双精度值。
返回值:此方法返回一个双精度值,该值刚大于传递的双精度值。
下面是说明nextDouble()方法的示例:
示例1:
// Java program to demonstrate
// nextDouble() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// getting double value just
// greater than the passed value
// using nextDouble() method
double value
= ChoiceFormat.nextDouble(22);
// display the result
System.out.print("Next greater double"
+ " value than 22: "
+ value);
}
}
输出:
Next greater double value than 22: 22.000000000000004
示例2:
// Java program to demonstrate
// nextDouble() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// calling getValue() mehtod
getValue(1.23d);
getValue(10d);
getValue(-12d);
getValue(1.2f);
getValue(50);
}
// defining getValue() mehtod
public static void getValue(double doub)
{
// getting double value just
// greater than the passed value
// using nextDouble() method
double value
= ChoiceFormat.nextDouble(doub);
// display the result
System.out.println("Next greater double"
+ " value than "
+ doub + ": " + value);
}
}
输出:
Next greater double value than 1.23: 1.2300000000000002 Next greater double value than 10.0: 10.000000000000002 Next greater double value than -12.0: -11.999999999999998 Next greater double value than 1.2000000476837158: 1.200000047683716 Next greater double value than 50.0: 50.00000000000001
参考: https://docs.oracle.com/javase/9/docs/api/java/text/ChoiceFormat.html#nextDouble-double-
相关用法
- Java ChoiceFormat format()用法及代码示例
- Java ChoiceFormat hashCode()用法及代码示例
- Java ChoiceFormat getFormats()用法及代码示例
- Java ChoiceFormat previousDouble()用法及代码示例
- Java ChoiceFormat parse()用法及代码示例
- Java ChoiceFormat setChoices()用法及代码示例
- Java ChoiceFormat getLimits()用法及代码示例
- Java ChoiceFormat equals()用法及代码示例
- Java ChoiceFormat applyPattern()用法及代码示例
- Java ChoiceFormat nextDouble(double, boolean)用法及代码示例
- Java Java lang.Long.reverse()用法及代码示例
- Java Java lang.Long.builtcount()用法及代码示例
- Java Java lang.Long.byteValue()用法及代码示例
- Java Java.util.Collections.disjoint()用法及代码示例
注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 ChoiceFormat nextDouble(double) method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。