Course contentsShow
← Java
Lesson 1033 of 2,87024. List ImplementationsFree lesson

Vector Growth Strategy: Doubling Capacity

Explore how Vector doubles its capacity by default, unlike ArrayList's 50% growth strategy.

Vector Growth Strategy: Doubling Capacity

What you'll learn: How Vector's capacity expansion differs significantly from ArrayList's more conservative growth approach.

Understanding Vector's Aggressive Growth

When a Vector needs more space and must resize its internal array, it follows a doubling strategy by default. This means if the current capacity is 10 elements and you add an 11th, Vector will create a new array with capacity 20—exactly double the previous size.

This contrasts sharply with ArrayList, which grows by approximately 50% (multiplying capacity by 1.5). If an ArrayList with capacity 10 needs to grow, it expands to around 15 elements, not 20.

Why the Difference Matters

Vector's doubling strategy reflects its older, more memory-generous design philosophy from early Java versions. Doubling means:

  • Fewer resizes needed as the collection grows large
  • More memory waste if you don't fill the vector completely
  • Larger jumps in memory consumption with each resize

Think of it like upgrading storage: ArrayList says "let's add 50% more closet space," while Vector says "let's double the entire closet." Vector's approach is faster for rapid growth but potentially wasteful.

The Trade-off

With Vector's doubling:

  • Growing from 1,000 to 2,000 elements means allocating 1,000 extra slots
  • With ArrayList's 1.5x growth, you'd allocate only ~500 extra slots

This exponential growth minimizes the number of expensive array-copy operations but maximizes the amount of unused memory after each resize.

Key Takeaway: Vector doubles its capacity during growth (100% increase), making it more aggressive than ArrayList's 50% growth strategy—trading memory efficiency for fewer resize operations.