日期:2014-05-20 浏览次数:20853 次
package File;
/*一段手机号码验证的程序
*/
class Error extends Exception
{
String s;
Error(String s)
{
this.s=s;
}
void tostring()
{
System.out.println(s);
}
}
class yinqing {
void jisuan(String s) throws Error{
String[] number={"135","136","137","138","139","159","134"};
String[] liantong={"133","132","130","131"};
char[] buf=new char[3];
char[] Lbuf=new char[3];
s.getChars(0, 3, Lbuf, 0);
s.getChars(0, 3, buf, 0);
String str=new String(buf);
String Lstr=new String(Lbuf);
if((s.length()==11))
{
for(int i=0;i <7;i++)
{
while(number[i].equals(str))
{
System.out.println("我是移动");
break;
}
}
for(int j=0;j <4;j++)
while(liantong[j].equals(Lstr))
{
System.out.println("我是联通");
break;
}
}
else
throw new Error("这是手机号嘛?我做个程序容易嘛我。");
}
}
public class NetWork_2 {
public static void main(String[] args) {
yinqing y=new yinqing();
try
{
y.jisuan("13861588939");
}
catch(Error e)
{
e.tostring();
}
}
}