How do you format something in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do you format something in java?

I want to format the number 75 to two decimal places and show a pound sign

19th Mar 2017, 4:25 PM
Melissa Martin
2 Answers
+ 11
float value = 75.0f; System.out.printf("%.2f
quot;, value);
19th Mar 2017, 8:57 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 1
You have variable declare as Float floatValue; To print number with decimal places System.out.println(String.format("%.2f", floatValue));
19th Mar 2017, 5:48 PM
Sergey L.