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

> 来源：梦飞idc云平台 | 原文：https://www.mfisp.com/13159.html | 发布：2022-11-24 | 更新：2022-11-24 | 分类：建站教程、投稿分享

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

 

> 提示：判断字符串中包含`@`和`.` 即可

 

> public staticvoid main(String[] args) {  
> String str = “1732194588@qq.com”;  
> int i = str.indexOf("@");  
> int j = str.indexOf(".");  
>  boolean flag = true;  
> if (i==-1||j==-1){  
> flag=false;  
> }  
> System.out.println(flag);  
> }
> 
>  
> 
> ![使用indexOf方法判断Email邮箱是否合法](https://www.mfisp.com/wp-content/uploads/2021/10/20220921131641EIna1w.jpeg)

---
本页由 梦飞idc云平台（https://www.mfisp.com）提供。站点导航见 https://www.mfisp.com/llms.txt
