Check out example codes for "how to set 2 decimal places in java". It will help you in understanding the concepts better.

Code Example 1

printf(%.2f);

Code Example 2

DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
System.out.println(df.format(decimalNumber));

Learn ReactJs, React Native from akashmittal.com