+ 3
Double is a floating point type, so it should look like that:
123,456.123. You can use the DecimalFormat class, or simply:
Double n = 123456.123;
String formated = String.format("%,.3f", n);
System.out.println(formated);
If you meant integer/long value and without the existing formatting methods, here is one solution:
https://code.sololearn.com/c515aDvAvrne/?ref=app
Otherwise, simply:
int n = 123456789;
String formated = String.format("%,d", n);
System.out.println(formated);
+ 1
Done with JS
https://code.sololearn.com/WJ2PxwdKtJ8N/?ref=app