public class ArrayExceptionTest {
public static void main(String[] args) {
new ArrayExceptionTest().run();
}
private void run() {
try {
int a[] = new int[2];
a[4] = 0;
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("exception: " + e.getMessage());
e.printStackTrace();
}
}
}
ArrayExceptionTest.java output
exception: null
java.lang.ArrayIndexOutOfBoundsException
at ArrayExceptionTest.run(ArrayExceptionTest.java:10)
at ArrayExceptionTest.main(ArrayExceptionTest.java:3)
Tag: Study Code Program Java
No comments:
Post a Comment