There is a little trick - you multiply by 10^n where n is the number of decimal points you want, add 0.5, take integer, and divide result by 10^n. E.g. try this,
public class Rounder {
public static void main(
String[] args) {
double n = 6; //no. of decimal places
double x = 123.12345678901234; //no. to be rounded
double y = (int)(x*Math.pow(10,n)+0.5)/Math.pow(10,n);
System.out.println(y); //result
}
}
Hope this helps,
Alastair