Just five minutes ago I found out how ArrayList
works. It has elementData
field which is array with specific type, if we add element and elementData
array is full, collection internally create another array by this formula:
(oldCapacity * 3) / 2 + 1
And copy data from old array to new one. I`m just wondering, why is that? why not just double last size? where can i get more theoretical information about internal representation of ArrayList collection with describing this formula. P.S. Sorry for my English, its not my native language.