ChoiceFormat setChoices() method in Java with Examples
The setChoices() method of java.text.ChoiceFormat class is used to set the new Choice item with a defined limit and format in Choiceformat object.
public void setChoices(double limits, String formats)
Parameter: This method takes the following parameters:
- limits: which is the array of double values which will contain limit for choiceitem.
- format: which is the array of string values which will contain the format for choiceitem.
Return Value: This method does not return anything.
Exception: This method throws NullPointerException if limit or format is null.
Below are the examples to illustrate the setChoices() method:
updated Choiceformat object: 1.0#sun|2.0#mon|3.0#tue
Limit or Format is null Exception thrown: java.lang.NullPointerException
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.