How to format a number with thousands separator (commas) in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
      int x = 49876173;

      System.out.printf("%,d\n", x);
    }
}



/*
run:

49,876,173

*/

 



answered Dec 28, 2020 by avibootz

Related questions

1 answer 166 views
1 answer 221 views
1 answer 127 views
1 answer 138 views
1 answer 124 views
1 answer 142 views
2 answers 213 views
...