Currency.getCurrencyCode() in Java

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

Syntax:

String java.util.Currency.getCurrencyCode()

This method gets the ISO 4217 currency code of this currency.

Parameters: NA

Returns: the ISO 4217 currency code of this currency.

Exceptions: NA

Approach

Java

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

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

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

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

    }
}

Output:

USD


No comments:

Post a Comment