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);
}
}
}
{
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);
}
}
}
我忘了在程序的最后最后加上“System.exit(0);”了,请原谅
小满,现在越来越牛b了啊,工作怎么样啊,比较爽吧