This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

diff b/w vector and array list?  RSS feed

 
jamesu rajk
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends,

i am new to java,i want to know the differnce b/w ther

vector and arraylist?


can any body help me
 
Sidd Kulk
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch!!

The best possible way to understand this would be to go through the java documentation.
Although, to state few differences among many, Vector is nothing but the synchronized version of ArrayList. By synchronized, I mean that an ArrayList can be simultaneously accessed by multiple threads, while a Vector cannot be. It thus provides protection against illegal data manipulation(a crude word).

Sid
Njoy!!
 
Campbell Ritchie
Marshal
Posts: 55715
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not going in for gross oversimplifications, are we, Sidd Kulk?

You are right to imply the two are very similar, and Vector is synchronized, but,
  • The ArrayList API page says how to synchronize ArrayList,
  • and Vector predates ArrayList by two versions.
  • ArrayList is an unsynchronized implementation of the List interface, and Vector had to be altererd to implement List afterwards. It's all in the API docs.
     
    Sidd Kulk
    Ranch Hand
    Posts: 152
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Not of course, Ritchie. I just stated the simplest difference that came to my mind. Of course, one can go upto implementation level differences.


    Sid.
    Njoy!!!
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!