Home » Java programming language

Java Currency getDefaultFractionDigits() Method with Example

Currency Class getDefaultFractionDigits() method: Here, we are going to learn about the getDefaultFractionDigits() method of Currency Class with its syntax and example.
Submitted by Preeti Jain, on February 12, 2020

Currency Class getDefaultFractionDigits() method

  • getDefaultFractionDigits() method is available in java.util package.
  • getDefaultFractionDigits() method is used to get the default fraction digits of this Currency.
  • getDefaultFractionDigits() method is a non-static method, so it is accessible with the class object and if we try to access the method with the class name then we will get an error.
  • getDefaultFractionDigits() method does not throw an exception at the time of returning default fraction digits.

Syntax:

    public int getDefaultFractionDigits();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of this method is int, it returns number of default fraction of this Currency.

Example:

// Java program is to demonstrate the example of
// getDefaultFractionDigits() method of Currency

import java.util.*;

public class GetDefaultFractionDigitsOfCurrency {
    public static void main(String args[]) {
        // Instantiates a currency with INR code
        Currency currency = Currency.getInstance("INR");

        // By using getDefaultFractionDigits() method is 
        // to get the default fraction digits of this Currency
        int curr_def_frac_digits = currency.getDefaultFractionDigits();

        // Display Currency Default Fraction Digits
        System.out.print("currency.getDefaultFractionDigits(): ");
        System.out.println(curr_def_frac_digits);
    }
}

Output

currency.getDefaultFractionDigits(): 2





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.