☰
d2jsp
Rules
Help
Forum Gold FAQ
Live Streams
Photo Gallery
Hourly Raffle
Ladder Slasher
Log In
Register
Log In
Register
Account Recovery
Resend Validation Email
d2jsp Forums
>
Off-Topic
>
Computers & IT
>
Programming & Development
> How To Print Variable With Value, With Commas?
Add Reply
New Topic
New Poll
Views: 598
Replies: 4
Track Topic
ferf
Member
Posts: 31,391
Joined: Mar 25 2009
Gold
:
99.00
#1
Aug 19 2018 10:49pm
for example:
int ferfy = 1_500_700_900;
System.out.println(ferfy);
^but with commas instead of underscores. thanks!
Necrosummon
Member
Posts: 95
Joined: Apr 7 2017
Gold
:
156.00
#2
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
Klexmoo
Member
Posts: 12,703
Joined: May 17 2013
Gold
:
2,935.00
#3
Aug 20 2018 07:45am
https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html
labatymo
Member
Posts: 2,754
Joined: Nov 26 2007
Gold
:
1,339.81
#4
Aug 20 2018 09:10am
Use NumberFormat with grouping.
Code
NumberFormat numberFormat = NumberFormat.getInstance( );
numberFormat.setGroupingUsed( true );
numberFormat.format( ferfy );
ferf
Member
Posts: 31,391
Joined: Mar 25 2009
Gold
:
99.00
#5
Aug 20 2018 11:41am
Thanks guys!!!
Go Back To
Programming & Development
Topic List
Add Reply
New Topic
New Poll
© 2003-2024 d2jsp
Contact