This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector Over ArrayList in term of Capacity..!!

 
Saral Saxena
Ranch Hand
Posts: 203
Eclipse IDE Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 4846
34
Chrome Netbeans IDE Windows
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic