Java Currency getInstance Example


Syntax is : public static Currency getInstance(Locale locale)
This is static method. Method returns the Currency instance for the country of the given locale or returns null for territories that don't have a currency, such as Antarctica.

Here is the code.

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

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

Output of the program.
Currency instance for the given code is = CNY

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

HOME | COPYRIGHT | CONTACT US