欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

随机生成手机号

最编程 2024-04-08 13:46:47
...
//随机生成手机号码前3位
public static String randomPhonoNum(){
int[] mobileStart = {139,138,137,136,135,134,159,158,157,150,151,152,188,130,131,132,156,155,133,153,189,180,177,176};
Random r = new Random();
ArrayList<Integer> mobileList = new ArrayList<>();
for(int i = 0;i<mobileStart.length;i++){
mobileList.add(mobileStart[i]);
}

Random r1 = new Random();
String temp = "";
for(int i=0;i<8;i++){
if(i==4){
temp += "";
}
temp += r1.nextInt(10);
}
return mobileList.get(r.nextInt(mobileList.size()))+temp;
}