Formatting: how to print a float with 2 decimal places in Java?

PHOTO EMBED

Thu Sep 15 2022 02:26:36 GMT+0000 (Coordinated Universal Time)

Saved by @vsilveira #java

float myFloat = 2.001f;

String formattedString = String.format("%.02f", myFloat);
content_copyCOPY

https://stackoverflow.com/questions/2538787/how-to-print-a-float-with-2-decimal-places-in-java