ArrayList vs Vector : Collection Interview question

Advertisements

  Top Tutorials     New Tutorials     Submit     Login     Register  

Tutorial Detail

ArrayList vs Vector : Collection Interview question

Difference between ArrayList and Vector is the most common Core Java Interview question you will come across in Collection . This question is mostly
http://javahungry.blogspot.com/2013/12/difference-between-arraylist-and-vector-in-java-col...
  • Total Hits: 3577

  • Average Rating :
    URL RatingURL RatingURL RatingURL RatingURL Rating

  •  

  • Total Votes: 139 votes

  • Category: JAVA/Collections

  • Submitted on: 2013-12-09 05:30:15

  • Submitted By: Java Hungry

  • Set as Favorite

Description:

Difference between ArrayList and Vector is the most common Core Java Interview question you will come across in Collection . This question is mostly used as a start up question by the Interviewers before testing deep roots of the Collection .Vector , ArrayList classes are implemented using dynamically resizable array providing fast random access and fast list traversal very much like using an ordinary array . ArrayList support dynamic arrays that can grow as needed that is ArrayList can be dynamically increased or decreased in size .


Arraylist vs Vector in Java


1. Synchronization and Thread-Safe

Vector is synchronized while ArrayList is not synchronized . Synchronization and thread safe means at a time only one thread can access the code .In Vector class all the methods are synchronized .Thats why the Vector object is already synchronized when it is created .

2. Performance

Vector is slow as it is thread safe . In comparison ArrayList is fast as it is non synchronized . Thus in ArrayList two or more threads can access the code at the same time , while Vector is limited to one thread at a time.

3. Automatic Increase in Capacity

A Vector defaults to doubling size of its array . While when you insert an element into the ArrayList , it increases its Array size by 50% .    More detail...

Rating Detail

 Stars  Percentage  Total Vote
 One star  Vote LeftVote MiddleVote Right 38.85%  54
 Two starsTwo star  Vote LeftVote MiddleVote Right 10.07%  14
 Three starsThree starsThree stars  Vote LeftVote MiddleVote Right 11.51%  16
 Four starsFour starsFour starsFour stars  Vote LeftVote MiddleVote Right 10.79%  15
 Five starsFive starsFive starsFive starsFive stars  Vote LeftVote MiddleVote Right 28.78%  40

Caste Your Vote

 Rating  Selection  Guidelines
 Poor:     Very disappointing, useless.
 Fair:     Below average, disappointing but not useless.
 Good:     About average in its class.
 Very Good:     Above average for its category.
 Excellent:     One of the best Tutorials in its category.





Advertisements
Advertisements