how to print a number upto 2 decimal places in java code example
Example 1: print up to 2 decimal in java
System.out.printf("%.2f", value);
Example 2: decimal up to 6 places in java
double num = 1.34567;
System.out.format("%.4f", num);
System.out.printf("%.2f", value);
double num = 1.34567;
System.out.format("%.4f", num);