Java examples for Language Basics:Number Format
Using the comma (,) flag to display numbers with thousands separator.
public class Main { public static void main(String[] args) {//from ww w. j a v a 2 s . c om System.out.printf("%,d\n", 58625); System.out.printf("%,.2f\n", 58625.21); System.out.printf("%,.2f", 12345678.9); } }