使用 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