Currency getSymbol() in Java

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

Syntax:

String java.util.Currency.getSymbol()

This method gets the symbol of this currency for the default DISPLAY locale.

Parameters: NA

Returns: the symbol of this currency for the default DISPLAY locale.

Exceptions: NA

Approach

Java

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

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

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

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

    }
}

Output:

$


No comments:

Post a Comment