Java Currency getDefaultFractionDigits() Method
Description
The Java Currency getDefaultFractionDigits() method gets the default number of this currency's fraction digits.
Declaration
Following is the declaration for java.util.Currency.getDefaultFractionDigits() method
Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.
Parameters
NA
Return Value
This method returns the default number of fraction digits used with this currency
Exception
NA
Getting Default Fraction Digits of EUR Currency Instance Example
The following example shows the usage of Java Currency getDefaultFractionDigits() method for EUR currency. We've first created a currency object using EUR as currency code and then its default fraction digits are printed.
Output
Let us compile and run the above program, this will produce the following result −
Default fraction digits for EUR = 2
Getting Default Fraction Digits of USD Currency Instance Example
The following example shows the usage of Java Currency getDefaultFractionDigits() method for USD currency. We've first created a currency object using USD as currency code and then its default fraction digits are printed.
Output
Let us compile and run the above program, this will produce the following result −
Default fraction digits for USD = 2
Getting Default Fraction Digits of JPY Currency Instance Example
The following example shows the usage of Java Currency getDefaultFractionDigits() method for JPY currency. We've first created a currency object using JPY as currency code and then its default fraction digits are printed.
Output
Let us compile and run the above program, this will produce the following result −
Default fraction digits for JPY = 0