fork(2) download
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println("Rounded: " + round(2.655d,2)); // -> 2.65
		System.out.println("Rounded: " + round(1.655d,2)); // -> 1.66
	}
	
	static Double round(Double d, int precise)
	{
		
	    BigDecimal bigDecimal = new BigDecimal(d);
	    System.out.println("Before round: " + bigDecimal.toPlainString());
	    bigDecimal = bigDecimal.setScale(precise, RoundingMode.HALF_UP);
	    System.out.println("After round: " + bigDecimal.toPlainString());
	    return bigDecimal.doubleValue();
	}

}
Success #stdin #stdout 0.06s 380224KB
stdin
Standard input is empty
stdout
Before round: 2.654999999999999804600747665972448885440826416015625
After round: 2.65
Rounded: 2.65
Before round: 1.6550000000000000266453525910037569701671600341796875
After round: 1.66
Rounded: 1.66