Using group separators.
import java.util.Formatter;
public class Main {
public static void main(String[] argv) throws Exception {
Formatter fmt = new Formatter();
fmt.format("No group separators: %d\n", 123456789);
fmt.format("With group separators: %,d\n\n", 123456789);
System.out.println(fmt);
}
}
/*No group separators: 123456789
With group separators: 123,456,789
*/
Related examples in the same category