Java Data Type Tutorial - Java Currency.getInstance(String currencyCode)








Syntax

Currency.getInstance(String currencyCode) has the following syntax.

public static Currency getInstance(String currencyCode)

Example

In the following code shows how to use Currency.getInstance(String currencyCode) method.

//from  ww  w.  ja  v  a2  s .c o  m

import java.util.Currency;

public class Main {

   public static void main(String args[]) {

      // create a currency object with specified currency code
      Currency curr = Currency.getInstance("USD");

      System.out.println("Currency code :" + curr.getCurrencyCode());
   }
}

The code above generates the following result.