Code example for ChoiceFormat

0
            ChoiceFormat.nextDouble(2) };
 
    String[] formats = new String[] { "Less than one", "one",
            "Between one and two", "Greater than two" }; 
 
    ChoiceFormat f1 = new ChoiceFormat(limits, formats);
 
    /** 
     * @tests java.text.ChoiceFormat#ChoiceFormat(double[], java.lang.String[]) 
     */ 
    public void test_Constructor$D$Ljava_lang_String() { 
        // Test for method java.text.ChoiceFormat(double [], java.lang.String 
        // []) 
        String formattedString;
        double[] appleLimits = { 1, 2, 3, 4, 5 };
        String[] appleFormats = { "Tiny Apple", "Small Apple", "Medium Apple",
                "Large Apple", "Huge Apple" }; 
        ChoiceFormat cf = new ChoiceFormat(appleLimits, appleFormats);
 
        formattedString = cf.format(Double.NEGATIVE_INFINITY);