Java.util.Currency.getSymbol() Method



Description

The java.util.Currency.getSymbol() method returns the symbol of this currency for the default locale.

Declaration

Following is the declaration for java.util.Currency.getSymbol() method

public String getSymbol()

Parameters

NA

Return Value

This method returns currency's symbol for the default locale.

Exception

NA

Example

The following example shows the usage of java.util.Currency.getSymbol() method.

package com.tutorialspoint;

import java.util.*;

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

      // create a currency for euro
      Currency curr = Currency.getInstance("EUR");

      // get and print the symbol of the currency
      String symbol = curr.getSymbol();
      System.out.println("Currency symbol is = " + symbol);
   }
}

Let us compile and run the above program, this will produce the following result −

Currency symbol is = €
java_util_currency.htm
Advertisements