Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is difference between ArrayList and vector?  RSS feed

 
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
Bartender
Posts: 3179
34
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: 74
  • 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
Posts: 21088
85
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
Marshal
Posts: 55681
162
  • 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
Posts: 10573
65
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!