String fileName = "StringTest.jav";
String email = "tianhy@wingswind.com";
String obj = ".java";
int obj1 = fileName.indexOf(obj);
if (obj1 > 0 && obj1 != 1) {
System.out.println("Java文件名有效");
} else {
System.out.println("Java文件名无效!");
}
int index = email.indexOf('@');
int index1 = email.indexOf('.');
if (index < index1) {
System.out.println("邮箱格式正确");
} else {
System.out.println("邮箱格式错误!");
}