Home  >  Core Java

Example of Currency in Java

By Arvind Rai, May 31, 2013
In Java, Currency denotes a country currency. Currency is identified by their currency code. The object of Currency can be obtained by Locale or currency code. Currency has methods getDefaultFractionDigits, getCurrencyCode and getSymbol.
CurrencyDemo.java
package com.util;
import java.util.Currency;
public class CurrencyDemo {
    public static void main(String[] args) {
       Currency c = Currency.getInstance("INR");
       System.out.println(c.getDefaultFractionDigits());
       System.out.println(c.getCurrencyCode());
       System.out.println(c.getSymbol());
     }
}
Output
 2
INR
INR
POSTED BY
ARVIND RAI
ARVIND RAI
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us