you can catch array index out of bound exception.
rushikesh jadha
Junior Poster in Training
89 posts since Dec 2011
Reputation Points: 4
Solved Threads: 11
try {
// your code that could cause an exception to be thrown
} catch (Exception e) { // catch any Exception that may be thrown
// your code to display an error message
}
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
you can catch array index out of bound exception.
Never use try-catch for ArrayIndexOutOfBoundsException. You already know at runtime the size or length of what you are trying to use. So always check that.
long89:
So when looping, it is good to do this instead of what you have:
for (int i=0;i<people.length;i++) {
// use people[i]
}
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
please makes it as solve.
rushikesh jadha
Junior Poster in Training
89 posts since Dec 2011
Reputation Points: 4
Solved Threads: 11