Warning: Use of undefined constant fixed - assumed 'fixed' (this will throw an Error in a future version of PHP) in /home/webtro13/domains/farenda.com/public_html/wp-content/themes/moments/header.php on line 65

Java Programming Tutorials

Java programming tutorials with many code examples!

Java Util Currency toString


The method java.util.Currency.toString() overrides Object.toString() and returns the ISO 4217 currency code of this currency.

Method signature

The signature of the java.util.Currency.toString() method is as follows:

public String toString()

It overrides Object.toString().


The method takes no parameters.

Return value

Returns the ISO 4217 currency code of this currency.


The method throws no exceptions.

Example usage

In the following code we use java.util.Currency.toString():

package com.farenda.java.util;

import java.util.Currency;
import java.util.Locale;

public class CurrencyToString {

    public static void main(String[] args) {
        // For Chinese Yuan:
        Locale locale = Locale.CHINA;
        Currency currency = Currency.getInstance(locale);
        System.out.println("Currency toString(): "
                + currency.toString());

        // For Euro currency:
        currency = Currency.getInstance("EUR");
        System.out.println("Currency toString(): "
                + currency.toString());

The above code produces the following output:

Currency toString(): CNY
Currency toString(): EUR
Share with the World!