Java examples for Language Basics:Number Format
Here's an example that uses the NumberFormat class to format a double value as currency:
import java.text.NumberFormat; public class Main { public static void main(String[] args) { double salesTax = 2.425; NumberFormat cf = NumberFormat.getCurrencyInstance(); System.out.println(cf.format(salesTax)); }//from ww w .j a v a2 s . c om }