1 import java.text.*; 2 public class Gxjun 3 { 4 public static void main(String args[] ) 5 { 6 int n=123456789; 7 System.out.println("整数"+"按千分组号(带正好)"); 8 String s=String.format("%,+d",n); 9 System.out.println(s); 10 double number = 98765.6789 ; 11 System.out.println(number+"格式化为整数7位,小数3位"); 12 s=String.format("%011.3f",number); 13 System.out.println(s); 14 } 15 }
原文:http://www.cnblogs.com/gongxijun/p/3764567.html