Java Currency getInstance Example
Syntax is : public static Currency getInstance(String currencyCode)
This is static method. Method returns the Currency instance for the given currency code. For more currency code refer http://www.currencysystem.com/codes
Here is the code.
/**
* @(#) GetInstanceCurrency.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 GetInstanceCurrency {
public static void main( String args[] ){
/* use getInstance() method to create object of Currency object.
This is static method. */
Currency curr = Currency.getInstance("INR");
// For more currency code visit http://www.currencysystem.com/codes
System.out.println( "Currency instance for the given code is = "+curr);
}
} |
Output of the program.
| Currency instance for the given code is = INR |
|