public final String format(double number){
Scanner scan=new Scanner(System.in);
System.out.println("请输入一个数字:");
double number=scan.nextDouble();
System.out.println("该数字用Local类的常量作为格式化对象的构造参数,将获得不同的货币格式:");
//获取货币格式对象
NumberFormat format=NumberFormat.getCurrencyInstance(Locale.CHINA);
System.out.println("Locale.CHINA: "+format.format(number));
format=NumberFormat.getCurrencyInstance(Locale.US);
System.out.println("Locale.US: "+format.format(number));
}
06-11
759
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)