DecimalFormat setGroupingSize() method in Java
The setGroupingSize() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to set the grouping size for this DecimalFormat instance or not. The grouping size is the number of integers in each group in the integral part of a decimal number. For example, the grouping size of 123, 456.78 is 3 and that of 12, 34, 56.78 is 2.
public void setGroupingSize(int newSize)
Parameters: The function accepts a single parameter newSize which is the size of the new group of integers to be set.
Return Value: The function does not returns any value.
Below is the implementation of the above function:
12, 34, 56, 78.9
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.