Here we are describing the use of using exception class in java .This tutorial describes how to handle Array list exceptions appropriately in your programs and designs. The steps involved in the program are described below:-
ArraylistException.java
|
Output of the program
| Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 at java.util.ArrayList.add(ArrayList.java:367) at ArraylistException.buildAlphabet(ArraylistException.java:11) at ArraylistException.main(ArraylistException.java:18) Java Result: 1 |
To avoid this error you have to give proper index for
the List means to say starting index which is 0 for the array not 1.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Example to show ArraylistException in Java
Post your Comment