Java Currency - getSymbol() Method
The java.util.Currency.getSymbol() method is used to get the symbol of this currency for the default DISPLAY locale. For example, for the US Dollar, the symbol is "$" if the default locale is the US, while for other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code is returned.
Syntax
public String getSymbol()
Parameters
No parameter is required.
Return Value
Returns the symbol of this currency for the default DISPLAY locale.
Exception
NA.
Example:
In the example below, the java.util.Currency.getSymbol() method is used to get the symbol of the currency for the default locale.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a currency for euro Currency Curr = Currency.getInstance("EUR"); //getting and printing the currency symbol String symbol = Curr.getSymbol(); System.out.println("Currency symbol is: " + symbol); } }
The output of the above code will be:
Currency symbol is: €
❮ Java.util - Currency