? 問題一:
? 有int型數字如下,123,1234,12345,123456,1234567,12345678,123456789
? 求一個方法,輸出123 1,234 12,345 123,456 1,234,567 12,345,678 123,456,789
??處理:
? public void testPrint(int num) {
??? DecimalFormat format = new DecimalFormat("#,###");
??? System.out.println(format.format(num));
? }
?問題二、
double類型如何正確的轉換為字符串類型
處理:
?double d = 0.001;
??? DecimalFormat df1 = new DecimalFormat("#.####");
??? String result = df1.format(d);
??? System.out.println(result);
posted on 2006-03-22 15:53
xnabx 閱讀(901)
評論(2) 編輯 收藏 所屬分類:
Java