标签:
package leixifeng; import java.util.Scanner; public class Yanzheng { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("请输入金额"); String nums = input.next(); StringBuffer str =new StringBuffer(nums); for(int i = str.length()-3; i > 0 ; i-=3){ str.insert(i, ‘,‘); } System.out.println(str); } }
//StringBuffer 字符串的连接效率比String类高
标签:
原文地址:http://www.cnblogs.com/xiaolei121/p/5726742.html