Java examples for Language Basics:Number Format
Formatting output with class Formatter.
import java.util.Formatter; import javax.swing.JOptionPane; public class Main { public static void main(String[] args) {//from ww w. j ava 2 s. co m // create Formatter and format output Formatter formatter = new Formatter(); formatter.format("%d = %#o = %#X", 10, 10, 10); // display output in JOptionPane JOptionPane.showMessageDialog(null, formatter.toString()); } }