When my program throws the exception, i'm getting a return value of 7. What exactly does a 7 mean, and where can I get a list of these return values? Or is that just the first line where it happened (although i got a -1 one time)?
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7
at DataReader.get(Da开发者_运维知识库taReader.java:74)
at Employees.<init>(Employees.java:48)
at Main.main(Main.java:7)
That number is the number you tried to use as the argument of the get
call. It is not an error code.
It's the array index you were attempting to retrieve.
Your application code is trying to reference beyond the limits of the array. This could be caused by an index larger than the size of the array, or as your first exception indicated, passing in a negative index.
Check those conditions before a potentially risky array access, or at the very least wrap it in a try-catch block so you can recover and move on.
精彩评论