Java Currency getSymbol Example

Currency class getSymbol() method example. This example shows you how to use getSymbol() method.


Syntax is : public String getSymbol()
Method returns the symbol of this currency for the default locale. For example return symbol "$" if the specified locale is the US. If no symbol can be determined, the ISO 4217 currency code is returned.

Here is the code.

/**
 * @(#) GetSymbolCurrency.java
 * A class representing use of method getSymbol() of Currency class
 in java.util Package.
 * @Version  21-May-2008
 @author   Rose India Team
 */
import java.util.*;

class GetSymbolCurrency {
    public static void mainString args[] ){
        // This is field of Locale class <public static final Locale CHINA>
        Locale locale = Locale.US;
        /* use getInstance() method to create object of Currency class with
    argument of Locale type. This is static method. */
        Currency curr = Currency.getInstance(locale);
    String symbol = curr.getSymbol();
        System.out.println"Currency symbol for the given Locale is = "+symbol);
   }
}

Output of the program.
Currency symbol for the given Locale is = $

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US