d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > How To Print Variable With Value, With Commas?
Add Reply New Topic New Poll
Member
Posts: 31,391
Joined: Mar 25 2009
Gold: 99.00
Aug 19 2018 10:49pm
for example:

int ferfy = 1_500_700_900;
System.out.println(ferfy);



^but with commas instead of underscores. thanks!
Member
Posts: 95
Joined: Apr 7 2017
Gold: 156.00
Aug 19 2018 11:43pm
Float for decimal values. But if you want show 1, 500, 700, 900 use a string like

string ferfy = "1 , 500, 700, 900";

This post was edited by Necrosummon on Aug 19 2018 11:45pm
Member
Posts: 12,703
Joined: May 17 2013
Gold: 2,935.00
Member
Posts: 2,754
Joined: Nov 26 2007
Gold: 1,339.81
Aug 20 2018 09:10am
Use NumberFormat with grouping.

Code
NumberFormat numberFormat = NumberFormat.getInstance( );
numberFormat.setGroupingUsed( true );
numberFormat.format( ferfy );
Member
Posts: 31,391
Joined: Mar 25 2009
Gold: 99.00
Aug 20 2018 11:41am
Thanks guys!!!
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll