Currency getNumericCodeAsString() in Java

getNumericCodeAsString(): This method is available in java.util.Currency class of Java.

Syntax:

String java.util.Currency.getNumericCodeAsString()

This method returns the 3 digit ISO 4217 numeric code of this currency as a String.

Parameters: NA

Returns: the 3 digit ISO 4217 numeric code of this currency as a String.

Exceptions: NA

Approach

Java

import java.util.Currency;
import java.util.Locale;

public class CurrencygetNumericCodeAsString {
    public static void main(String[] args) {

        Currency currency = Currency.getInstance(Locale.US);

        System.out.println(currency.getNumericCodeAsString());

    }
}

Output:

840


No comments:

Post a Comment