I get exception Exception in thread \"main\" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 for the below code. But couldn\'t understand why.
Exception in thread \"main\" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
ArrayList is not self-expandable. To add an item at index 1, you should have element #0.