Using the comma (,) flag to display numbers with thousands separator. - Java Language Basics

Java examples for Language Basics:Number Format

Description

Using the comma (,) flag to display numbers with thousands separator.

Demo Code

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);
   } 
}

Result


Related Tutorials