java异常问题,高手请进,帮帮忙啊。

2024-11-25 23:23:49
推荐回答(2个)
回答1:

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);
}
}

回答2:

晕!就这样还需要高手?

纯属懒人!