Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is difference between ArrayList and vector?

 
Mary Jones
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is difference between ArrayList and vector?
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean java.util.ArrayList and java.util.Vector ? if yes, please search in Beginners Forums or Java In General forums >> SearchFirst

Update: I asked for the clarification as this was earlier posted in JavaFX forum.
 
Nico Van Brandt
Ranch Hand
Posts: 69
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Literally from the Java API:

ArrayList
(This class is roughly equivalent to Vector, except that it is unsynchronized.)


Vector
Unlike the new collection implementations, Vector is synchronized.
 
swapnil kataria
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as said above vector is synchrnoized and 2nd thing vector are accessible by iterator and enumeration both,
 
Randall Fairman
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ArrayList is much faster than Vector, and only takes something like 10% more time to access than a simple array. I forget exactly where I saw this, but it wouldn't be a very hard thing to verify for yourself.
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Much faster? Perhaps a few Java versions ago when the (mostly unnecessary) synchronization had a bigger performance hit, but these days the difference in performance is probably minimal.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48976
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch Mary Jones.
 
bit developer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There are a few differences between arraylist and vector. Visit this link for the differences:
http://www.questionscompiled.com/answer.jsp?technology=java&qid=53

 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bit developer wrote:There are a few differences between arraylist and vector...

You do realize that you've replied to a post that's nearly two years old? I suspect Mary has left the building.

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic