We would like to know how to set total width and decimal width for float point value.
import java.util.Formatter; // ww w.java 2s . c o m public class MainClass { public static void main(String args[]) { Formatter fmt = new Formatter(); fmt.format("|%10.2f|", 123.123); System.out.println(fmt); } }
The code above generates the following result.