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.
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.