Java Currency Class: toString() Method

public String toString()

The toString() method is used to get the ISO 4217 currency code of a given currency.

Package: java.util

Java Platform: Java SE 8


Return Value:

the ISO 4217 currency code of this currency

Return Value Type: String

Example: Java Currency class: toString() Method

The following example fills aJava Currency class: toString() Method

import java.util.*;

public class Main {
   public static void main(String args[]) {

    // Create a currency with specific currency code
      Currency curr = Currency.getInstance("YER");

    // Get the currency string and display it
      System.out.println("String representation: " + curr.toString());


String representation: YER

Java Code Editor:

Previous:getSymbol Method
Next:Java String Methods

Follow us on Facebook and Twitter for latest update.