Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Array List vs Vector  RSS feed

 
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?
 
Rancher
Posts: 42975
76
  • 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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vector is synchronized, ArrayList isn't.
 
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.
 
Did you just should on me? You should read this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!