• Post Reply Bookmark Topic Watch Topic
  • New Topic

Read on ArrayList vs Vector in Collections  RSS feed

 
santhoshkumar kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my blog post on ArrayList vs Vector - http://myprogressivelearning.wordpress.com/2014/12/17/why-to-prefer-arraylist-over-vector-in-java-collections-differences/ . Please provide valuable comment on it. To increase the knowledge. [not to promote]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cover a lot of differences. I see a key thing missing. That Vector was created before ArrayList and at one point the default choice. For new code that needs a synchronized collection, the Java 7 Collections classes are often preferable.
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's another thing you didn't mention -- Vector has some methods which ArrayList doesn't have. I'm not saying they are methods which can't be replaced, but a couple of years ago when I was refactoring some code which used Vector, I left it alone because it used them.

Apart from that, the article was a blast from the past. People used to really care back in 2004. For some reason I never understood, they resented the fact that Vector was obsolete and they would go to ridiculous lengths to "explain" why Vector should be used.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:For new code that needs a synchronized collection, the Java 7 Collections classes are often preferable.

Non-crappy concurrent collections (e.g. ArrayBlockingQueue or ConcurrentHashMap) started becoming available in JDK 5, and each release since then has added more. Nowadays it's also worth considering GS Collections which offer additional functionality and performance enhancements.
 
santhoshkumar kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Boyarsky & @Simmons Thank you for lighting me on new collections. I will try to learn the latest collections which gives better performance and update the post. @Clapham Thank you. I believe for performance centric applications, we should avoid using the Vector.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!