yangxin
发贴: 5
积分: 0
|
于 2005-11-15 17:38
大家好!小弟正在学习JAVA,练习写了个小应用程序,但是错漏百出,找了半天却找不出什么问题?特来请问大伙. 原代码如下: import java.text.Format;
public class NumberFormat { public static void main(String args[]) { double x = 1000.0/3.0; NumberFormat formatter = NumberFormat.getNumberInstance(Locale.CHINA); System.out.println(formatter.format(x)); formatter = NumberFormat.getCurrencyInstance(Locale.CHINA); System.out.println(formatter.format(x)); // 显示尾随的0 x = NumberFormat.setMaximumFractionDigits(2); x = NumberFormat.setMinimumFractionDigits(2); System.out.println(formatter.format(x)); // 截断错误 x = NumberFormat.setMinimumIntergerDigits(2); System.out.println(formatter.format(x)); } // end of class:main } 先谢谢大家了!
why edited on 2005-11-15 18:19
|