Sebastian Janisch wrote:If there is no value present at position 4534234 in an ArrayList, then list.get(4534234 ) will automatically return null. There is absolutely no use for a null value in a List.
If an ArrayList (and any other List implementation) has less than 4534235 elements, then list.get(4534234) will throw an IndexOutOfBoundsException. It will not return null.
It will only return null if the value at position 4534234 is null - and guess what, that means that the List contains null values.
If you get an unknown List reference, there is just one way to find out - try it:
This does pose one threat - if add is allowed but remove isn't. That will leave your List with one trailing null element. I'm don't think you want that.