我无法弄清楚为什么我的代码没有正确编译..我可以通过代码直到它到达catch块.它工作,显示消息,所以我知道它正在捕捉错误.但是,它结束了我的程序,说我在同一个地方有同样的错误.我看不出我做错了什么.谢谢你的帮助!!
class Verification {
String detAccess(String[] pL, String[] uL, String pass, String user) {
int pos = 0;
String access = "";
try {
for (int i=0; !user.equals(uL[i]); i++)
pos++;
} catch (ArrayIndexOutOfBoundsException exec) {
System.out.println("Username doesn't exist.");
throw exec;
}
if(pass.equals(pL[pos])) {
access = "MEMBER";
} else {
System.out.println("Incorrect password.");
access = "DENIED";
}
return access;
}
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
71 次 |
| 最近记录: |