Example usage for java.text ChoiceFormat format

List of usage examples for java.text ChoiceFormat format

Introduction

In this page you can find the example usage for java.text ChoiceFormat format.

Prototype

public final String format(double number) 

Source Link

Document

Specialization of format.

Usage

From source file:Main.java

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 + ").");
}