If you just want to print a double
with two digits after the decimal point, use something like this:
double value = 200.3456;
System.out.printf("Value: %.2f", value);
If you want to have the result in a String
instead of being printed to the console, use String.format()
with the same arguments:
String result = String.format("%.2f", value);
Or use class DecimalFormat
:
DecimalFormat df = new DecimalFormat("####0.00");
System.out.println("Value: " + df.format(value));