I need to give accuracy of a number entered by user till few digit. like if user enter some random value and gives that he wants accuracy till three digit then I need to rou
You can indeed use NumberFormat to do this
double amount = 15; NumberFormat formatter = new DecimalFormat("#0.000"); System.out.println("The Decimal Value is:"+formatter.format(amount));