标签:java os for ar new c ui 字符串
String str1 = "123456789"; str1 = new StringBuilder(str1).reverse().toString(); //先将字符串颠倒顺序 String str2 = ""; for(int i=0;i<str1.length();i++){ if(i*3+3>str1.length()){ str2 += str1.substring(i*3, str1.length()); break; } str2 += str1.substring(i*3, i*3+3)+","; } if(str2.endsWith(",")){ str2 = str2.substring(0, str2.length()-1); } System.err.println(new StringBuilder(str2).reverse().toString());
《java中把金额以3位分开的计数法》,布布扣,bubuko.com
标签:java os for ar new c ui 字符串
原文地址:http://my.oschina.net/u/1269023/blog/298004