StringBufferDemo(将一个数字字符串转换成逗号分隔的数字串)
package
practice2;
import
java.util.Scanner;
public
class StringBufferDemo {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Please iput a series of numbers:");
String num = input.next();
StringBuffer sb = new StringBuffer(num);
for (int i = sb.length() - 3; i > 0; i = i - 3) {
sb.insert(i, ',');
}
System.out.println(sb);
}
}