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.


/* w w w  .ja  va 2 s  .  co  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.