This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Vector Over ArrayList in term of Capacity..!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Vector Over ArrayList in term of Capacity..!!" Watch "Vector Over ArrayList in term of Capacity..!!" New topic
Author

Vector Over ArrayList in term of Capacity..!!

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Hi Guys,
As I was going through differences between vector<T> & ArrayList<T> in that section I had gone through that You can specify how a Vector<T> object should increase its capacity when it is necessary whereas with an ArrayList<T> you cannot. You can have some control over how an ArrayList<T> increases in capacity by using its ensureCapacity() method that sets a given capacity and another thing You can discover the current capacity of a Vector<T> by calling its capacity() method. You have no way to know the current capacity of an ArrayList<T> unless you have set its capacity explicitly...!! Please guys can You help me improving this with a shortr example..!!
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3573
    
  14

Well why would you even want to know what the capacity is in the first place? It's an implementation detail that makes the list work reasonably fast, and beyond the ensureCapacity() method not very interesting. They did well hiding this stuff from the client.

And Vector is pretty much obsolete. Just pretend it's not part of the standard API.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vector Over ArrayList in term of Capacity..!!
 
Similar Threads
ArrayList vs Vector Size and Capacity difference ?
Collections Framework - use of Vector
doubt in String
Differences beteween ArrayList and Vector.
differences between Vector and ArrayList