使用indexOf方法判断Email邮箱是否合法

使用 indexof方法判断Email邮箱是否合法

提示:判断字符串中包含@和. 即可

public  staticvoid main(String[] args) {
String str = “[email protected]”;
int i = str.indexOf(“@”);
int j = str.indexOf(“.”);
 boolean flag = true;
if (i==-1||j==-1){
flag=false;
}
System.out.println(flag);
}

0

评论0

请先
显示验证码
没有账号?注册  忘记密码?