判断手机号码运营商

本文提供了一个Java方法用于判断中国大陆手机号所属的运营商类型,包括电信、移动、联通及虚拟运营商,并给出具体实现代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    /**
     * 判断手机号的类型
     * 更新时间 2016-11-07
     * @param $mobile
     * @return int  1:电信 2:移动 3:联通 4:虚拟运营商 10:未知
     */
    public static int  getMobileType(String $mobile){
        String $prefix = $mobile.substring(0, 3);
        String telcomm [] = new String[]{"133","153","154","181","180","189","177"};
        String mobilecomm [] = new String[]{"134","135","136","137","138","139","147","150","151","152","157","158","159","178","182","183","184","187","188"};
        String unioncomm [] = new String[]{"130","131","132","155","156","185","186","145","176"};
        String virtualcomm [] = new String[]{"170","177"};
        
        if(Arrays.asList(telcomm).contains($prefix))
            return 1;
        else if(Arrays.asList(mobilecomm).contains($prefix))
            return 2;
        else if (Arrays.asList(unioncomm).contains($prefix))
            return 3;
        else if (Arrays.asList(virtualcomm).contains($prefix))
            return 4;
        else
            return 10;
    }
}

 

转载于:https://www.cnblogs.com/passedbylove/p/8556089.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值