dcsimg

How does ArrayList increase its capacity?

John Zukowski

Unlike Vector where you can specify a capacity increment, ArrayList doesn't support this. Instead, ArrayList will increase capacity by about a half when it runs out of space. The refernece implementation uses the forumla:

newCapacity = (oldCapacity * 3)/2 + 1
though, this isn't part of the class definition so others can implement it differently.