Java Data Type Tutorial - Java Currency.toString()








Syntax

Currency.toString() has the following syntax.

public String toString()

Example

In the following code shows how to use Currency.toString() method.

//from w w w  .  j  ava 2s.  com


import java.util.Currency;

public class Main {

   public static void main(String[] args) {

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

      System.out.println(curr.toString());
   }
}

The code above generates the following result.