1.实现代码
public class StringUtil {
public static String blurPhoneNumber(String phoneNumber) throws Exception{
if (!(phoneNumber instanceof String) || phoneNumber.length()!= 11) {
throw new Exception("传入的号码不规范");
}
StringBuilder str = new StringBuilder(phoneNumber.substring(0, 3));
str.append("****");
str.append(phoneNumber.substring(7));
System.out.println(str);
return str.toString();
}
public static void main(String[] args) throws Exception {
StringUtil.blurPhoneNumber("13600000000"); //136****0000
}
}