Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array List vs Vector

 
Muhammad Aasim
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is difference between ArrayList and Vector? In which situation we use arrayList and Vector?

Answer:-ArrayList is like a resizeable array. ArrayList actually comes as a replacement the old "Vector" Collection. As we add or remove elements into or from it, it grow or shrinks over time?

Any thing else may please be tell?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One difference is that the methods in Vector are all synchronized, whereas the methods in ArrayList are not. That's important in multi-threaded environments.
 
Fredrik Larsback
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vector is synchronized, ArrayList isn't.
 
Kaustav Ganguly
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing is Vector also implements a resizable array like ArrayList, so both are resizable data structures. Vector class is there in Java since the begining and ArrayList was intoduced as part of the Collection framework. Vector class is also retrofitted into the java collection framework to implement the List interface in Java 2 v1.2 . And finally Vector is synchronized and ArrayList is not.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic