Open In App

ChoiceFormat nextDouble(double) method in Java with Examples

Last Updated : 11 Aug, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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




// 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);
    }
}


Output: 

Next greater double value than 22: 22.000000000000004

 

Example 2: 

Java




// 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() method
        getValue(1.23d);
        getValue(10d);
        getValue(-12d);
        getValue(1.2f);
        getValue(50);
    }
 
    // defining getValue() method
    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);
    }
}


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-



Similar Reads

ChoiceFormat nextDouble(double, boolean) method in Java with Examples
The nextDouble(double, boolean) method of java.text.ChoiceFormat class is used to get the double value just greater than the passed double value if passed Boolean value is true or it will return the double value just lesser than the passed double value if passed Boolean value is false. Syntax: public static double nextDouble(double d, boolean posit
2 min read
Scanner nextDouble() method in Java with Examples
The nextDouble() method of java.util.Scanner class scans the next token of the input as a Double. If the translation is successful, the scanner advances past the input that matched. Syntax: public double nextDouble() Parameters: The function does not accepts any parameter. Return Value: This function returns the Double scanned from the input. Excep
4 min read
Random nextDouble() method in Java with Examples
The nextDouble() method of Random class returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence. Syntax: public double nextDouble() Parameters: The function does not accepts any parameter. Return Value: This method returns the next pseudorandom, uniformly distributed double
1 min read
ChoiceFormat equals() method in Java with Examples
The equals() method of java.text.ChoiceFormat class is used to compare between two ChoiceFormat objects and give the Boolean value regarding the comparison.Syntax: public boolean equals(Object obj) Parameter: This method takes obj as parameter which is another ChoiceFormat object for comparison.Return Value: This method returns true if both choice
2 min read
ChoiceFormat applyPattern() method in Java with Examples
The applyPattern() method of java.text.ChoiceFormat class is used to set the new pattern text for current ChoiceFormat by overriding the current limit and format. This new pattern will be the combination of limit and format of ChoiceFormatSyntax: public void applyPattern(String newPattern) Parameter: This method takes newPattern as parameter which
2 min read
ChoiceFormat getLimits() method in Java with Examples
The getLimits() method of java.text.ChoiceFormat class is used to get the attached limit to choice format object in time of initialization. It returns the array of double type with the limits.Syntax: public double[] getLimits() Parameter: This method does not accept any parameter.Return Value: This method returns limit attached to the choice format
2 min read
ChoiceFormat hashCode() method in Java with Examples
The hashCode() method of java.text.ChoiceFormat class is used to get the hash code for choice format object. This hashcode value is returned as an integer. Syntax: public int hashCode() Parameter: This method does not accept any parameter. Return Value: This method returns hash code for choice format object as an integer. Below are the examples to
2 min read
ChoiceFormat getFormats() method in Java with Examples
The getFormats() method of java.text.ChoiceFormat class is used to get the attached format to ChoiceFormat object in time of initialization. It provides the array of specified type.Syntax: public Object[] getFormats() Parameter: This method does not accept any parameter.Return Value: This method returns an array of the specified type which is the f
2 min read
ChoiceFormat previousDouble() method in Java with Examples
The previousDouble() method of java.text.ChoiceFormat class is used to get the double value just lesser than the passed double value.Syntax: public static final double previousDouble(double d) Parameter: This method accepts double value d as a parameter for which the previous double value is returned.Return Value: This method returns an double valu
2 min read
ChoiceFormat parse() method in Java with Examples
The parse() method of java.text.ChoiceFormat class is used to get the limit value for particular format in ChoiceFormat object. Syntax: public Number parse(String text, ParsePosition status) Parameter: This method takes the following parameters: text: which is the text for which limit value have to be found in String format.status: which is the ind
2 min read