string.format in java to print upto 2 decimal code example Example: print up to 2 decimal in java System.out.printf("%.2f", value);