public class CustomException {
private static String[][] ACCOUNT = { { "admin", "admin123" }, { "administrator", "456" }, { "jzh", "xlxlxl" } };
public static void main(String[] args ) throws LoginException {
for (String[] user : ACCOUNT) {
String username = "";
String password = "";
if (user.length > 1) {
username = user[0];
password = user[1];
}
if (username.equals("234") && password.equals("234"))
System.out.println("欢迎光临");
else
throw new LoginException("你的用户名或密码错误, 请重新输入");
}
}
}
/**
* @author Administrator 自定义异常
*/
class LoginException extends Exception {
LoginException ( ) {
super();
}
LoginException ( String message ) {
super(message);
}
}
晕!就这样还需要高手?
纯属懒人!