How to Format a double value to 2 decimal places
import java.text.*;
public class DecimalPlaces {
public static void main(String[] args) {
double d = 1.234567;
DecimalFormat df = new DecimalFormat("#.##");
System.out.print(df.format(d));
}
}
Description : How to confined the value in java upto two decimal places. Decimal value allowed only upto two spaces.
No comments:
Post a Comment
Your feedback may help others !!!