Choice Format Demo : Choice Format « I18N « Java






Choice Format Demo

 
import java.text.ChoiceFormat;

public class ChoiceFormatApp {
  public static void main(String args[]) {
    double limits[] = { 0.0, 0.1, 0.3, 0.7 };
    String labels[] = { "very low", "low", "moderate", "high" };
    ChoiceFormat format = new ChoiceFormat(limits, labels);
    double r = Math.random();
    
    System.out.println(format.format(r) + " (" + r + ").");
  }
}
//high (0.755370803805559).

 








Related examples in the same category

1.Java I18N: Format : Choice Format DemoJava I18N: Format : Choice Format Demo