The java.math.BigDecimal.min(BigDecimal val) method in Java is used to compare two BigDecimal values and return the minimum of the two.
public BigDecimal min(BigDecimal val)
Parameters: The function accepts a BigDecimal object val as parameter whose value is compared with that of this BigDecimal object and the minimum value is returned.
Return Values: This method returns the BigDecimal whose value is the smaller of this BigDecimal and val. In case if both are equal, this BigDecimal is returned.
Input : a = 17.000041900, b = 17.0000418999 Output : 17.0000418999 Input : a = 235900000146, b = 236000000000 Output : 235900000146
Below programs will illustrate min() function of BigDecimal class:
Minimum Value among 17.000041900 and 17.0000418999 is 17.0000418999
Length of string GeeksforGeeks is 13 Length of string GeeksClasses is 12 Minimum length is 12
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.