高手帮帮忙,一个小问题!

slovezhang 2003-08-20 09:32:51
用java编写一个小程序:验证Email地址的合法性!
...全文
29 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
slovezhang 2003-08-21
  • 打赏
  • 举报
回复
多谢小满拉,真是帮了我的大忙啊?!:)
林中漫步1982 2003-08-20
  • 打赏
  • 举报
回复
TO: bobfallen

哦靠, 没想到在这碰到你, 我都激动得快流泪了。

我好久没来CSDN了,你在北真牛
阎罗 2003-08-20
  • 打赏
  • 举报
回复
to : huqingmiao(小满)
小满,现在越来越牛b了啊,工作怎么样啊,比较爽吧
林中漫步1982 2003-08-20
  • 打赏
  • 举报
回复
有的网站的Email允许使用下画线,有的则禁止, 所以我没有对此判断。


我忘了在程序的最后最后加上“System.exit(0);”了,请原谅
林中漫步1982 2003-08-20
  • 打赏
  • 举报
回复
import javax.swing.JOptionPane;

public class ETest
{
public static void main(String[] args)
{
String mail=JOptionPane.showInputDialog(null,
"Please Enter your Email address:");

int index1=mail.indexOf('@');
String postfix=mail.substring(index1+1);
int index2=postfix.indexOf(".com");
int index3=postfix.indexOf(".net");


if(!Character.isLetter(mail.charAt(0))
||index1<0||index2<0||index3<0)
{
JOptionPane.showMessageDialog(null,
"Your Email address is not valid!",
"Wrong Email",
JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null,
"Your Email address is valid!","OK",
JOptionPane.INFORMATION_MESSAGE);
}
}
}

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧