首页 > 移动平台 > 详细

随机生成手机号码

时间:2014-09-10 17:18:40      阅读:173      评论:0      收藏:0      [点我收藏+]
    public static void main ( String[] args )
    {
       
        Test t = new Test();
        for (int i = 0; i < 100; i++) //随机生成100个手机号码
        {
            System.out.println(t.getPhone());
        }
        
    }
    /**
     * 随机生成11位手机号码
     */
    public String getPhone(){
        
        String 移动[]={"134","135","136","137","138","139","150","151","152","157","158","159","187","188"};
        String 联通[]={"130","131","132","155","156","185","186","145"}; 
        String 电信[]={"133","153","180","181","189"}; 
        String tel[][]={移动,联通,电信};
        Random rd=new Random();
        int index = rd.nextInt(tel.length);//运营商个数
        int size = rd.nextInt(tel[index].length); //各运营商号码个数
        String phone=tel[index][size]+""+rd.nextInt(10)+""+rd.nextInt(10)+""+rd.nextInt(10)+""+rd.nextInt(10)+""+rd.nextInt(10)+""+rd.nextInt(10)+""+rd.nextInt(10)+""+rd.nextInt(10);
        return phone;
    }

 

随机生成手机号码

原文:http://www.cnblogs.com/zhaojinhui/p/3964591.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!