1 public class RoundExample {
 2 
 3     public static double round(double value, int places) {
 4         int digits = (int) Math.pow(10, places);
 5         double result = Math.round(value * digits);
 6         return result / digits;
 7     }
 8 
 9     public static void main(String[] args) {
10         // round PI to 3 decimal places.
11         System.out.println(round(Math.E, 3));
12     }
13 
14 }