How to round to one decimal place in Java?

To round to one decimal place in Java, do this: Math.round(number * 10.0) / 10.0.

Here's how you do it:

double number = 123.456789;
double rounded = Math.round(number * 10.0) / 10.0;

System.out.println(rounded); // 123.5