java.util.Currency getSymbol()
Description
This is equivalent to calling getSymbol(Locale.getDefault(Locale.Category.DISPLAY)). As a reference the getSymbol method is overloaded which means that this method has more than one method implementation but with different method signature. One of the overloaded method is a getSymbol() without a method argument which we currently discussing, meanwhile the other overloaded method takes an argument Locale.
Method Syntax
public String getSymbol()
Method Argument
| Data Type | Parameter | Description |
|---|---|---|
| N/A | N/A | N/A |
Method Returns
The getSymbol() method of Currency class returns the symbol of this currency for the default DISPLAY locale.
Compatibility
Java 1.4
Java Currency getSymbol() Example
Below is a simple java example on the usage of getSymbol() method of Currency class.
package com.javatutorialhq.java.examples;
import static java.lang.System.*;
import java.util.Currency;
/*
* This example source code demonstrates the use of
* getSymnbol() method of Currency class.
*/
public class CurrencyGetSymbolExample {
public static void main(String[] args) {
// create an instance of Currency class
Currency currency = Currency.getInstance("JPY");
// get the symbol for Japanese Yen
out.println("Symbol of JPY in the current locale:" +
currency.getSymbol());
}
}
Basically on the above example, we just created a new Currency object with currency code of JPY with the intention of printing the currency symbol used for Japanese Yen using the getSymbol() method.
