w3resource

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

Syntax:

toString()
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());
   }
}

Output:

String representation: YER

Java Code Editor:

Previous:getSymbol Method
Next:Java String Methods



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/java-tutorial/util/currency/java_currency_toString.php