toString(): This method is available in java.util.Currency class of Java.
Syntax:
String java.util.Currency.toString()
This method returns the ISO 4217 currency code of this currency.
Parameters: NA
Returns: the ISO 4217 currency code of this currency.
Exceptions: NA
Approach
Java
import java.util.Currency;import java.util.Locale;public class CurrencytoString {public static void main(String[] args) {Currency currency = Currency.getInstance(Locale.US);System.out.println(currency.toString());}}
Output:
USD
No comments:
Post a Comment