ChoiceFormat nextDouble(double) method in Java with Examples
Last Updated :
11 Aug, 2021
The nextDouble(double) method of java.text.ChoiceFormat class is used to get the double value just greater than the specified double value.
Syntax:
public static final double nextDouble(double d)
Parameter: This method accepts double value d as a parameter for which the next double value is returned.
Return Value: This method returns an double value just greater than the passed double value.
Below are the examples to illustrate the nextDouble() method:
Example 1:
Java
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
double value
= ChoiceFormat.nextDouble( 22 );
System.out.print( "Next greater double"
+ " value than 22: "
+ value);
}
}
|
Output:
Next greater double value than 22: 22.000000000000004
Example 2:
Java
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
getValue( 1 .23d);
getValue(10d);
getValue(-12d);
getValue( 1 .2f);
getValue( 50 );
}
public static void getValue( double doub)
{
double value
= ChoiceFormat.nextDouble(doub);
System.out.println( "Next greater double"
+ " value than "
+ doub + ": " + value);
}
}
|
Output:
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
Reference: https://docs.oracle.com/javase/9/docs/api/java/text/ChoiceFormat.html#nextDouble-double-
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...