• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding Vector

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Friends,
Can any one tell How the Vector class object grows or expand his size dynamically,
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Nothing magic about it. Vector has an array member in which it keeps the element data, and a count of elements. It tries to keep the array a little larger than needed, so growing by a few elements just involves using some of that extra space and incrementing the counter. When the Vector runs out of extra space, it allocates a new, larger array, and copies the old data into it.

The source code for all the JDK API classes (which, in general, is well-documented and easy to read) is part of the JDK download. Look for JAVA_HOME/src.jar to see if you've already got it installed.
reply
    Bookmark Topic Watch Topic
  • New Topic