The getDefaultFractionDigits() Method of Currency class in Java is used to retrieve or know the fraction digits of this currency which is the default value set by the ISO 4217 currency code.
public int getDefaultFractionDigits()
Parameters: This method does not accept any parameters.
Return Value: This method returns an integer value which is the default fraction digits of the currency.
Exceptions: The method throws Runtime Error if an invalid code is called.
Below program illustrates the working of getDefaultFractionDigits() method:
INR's fractions digits are: 2
Jordan's fractions digits are: 3
Program 3: For an invalid Currency Code.
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.