123,456,789

package zuoye;

public class Demo01 {

//    
//    //12345678
//    String a = "12345678";   12,345,678
//    StringBuffer ab = new StringBuffer(a);
    
//    System.out.println();
//    
//    
//    for (int i = ; i > 0; i-=3) {
//        
//        
//    
//    }
    public static void main(String[] args) {
        
        String a = "12345678";   
        StringBuffer sb = new StringBuffer(a);
        
        for (int i = a.length()-3; i > 0; i-=3) {
            
            
            sb = sb.insert(i, ",");
            
        }
    
        
        System.out.println(sb);
    
        
        
    }
    
    
}

 

posted @ 2019-07-31 20:10  AxeBurner  阅读(822)  评论(0编辑  收藏  举报