If I use list.add(int, int)
method, it will throw an IndexOutBoundException
if the position is bigger than or equals to list.size()
.
I would like to have something that increases the size by adding null elements (if necessairy) until it can safely add a real element to the end.
So lets say I have a list(list.size()= 0)
, I want to add 5 to the third position, then I would get a list of where the size
equals to 4
, and the elements are null
, null
, null
, 5
.