StringBuffer .insert方法输出电话号码格式
package ch11;
import java.util.Scanner;
/**
* Created by liwenj on 2017/7/21.
*/
public class T7 {
public static void main(String[] args) {
String sz="13438377536";
StringBuffer sb=new StringBuffer(sz);
int len=sb.length();
int index=len-4;
while(true){
if (index>0){
sb.insert(index,"-");
index=index-4;
}else{
break;
}
}
System.out.println(sb);
}
}