• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Regarding ArrayList and Vector

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I know that arraylist and vector are roughly the same excerpt the fact that vector is synchronized.I want to know when exactly we use vector.A small case study wud be helpful.
Rgds
Kunal
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The vector basically can accept dynamic addition and deletion of elements where as an array can't.
Practical Examples where we use are...
1.Reservation system>>Airline or Railway >>Where u create a big list of names and u go on adding and deleting the reservations.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
he's not talking arrays, he's talking ArrayList.
Apart from synchronization there's no reason to use Vector at all.
ArrayList outperforms Vector everywhere and has a far richer API making it the preferred choice.
If you need synchronization using a synchronized ArrayList can well be preferred over a Vector because of those reasons.
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose old code has Vector used, should we ignore it completely and use synchronized ArrayList then? How do we handle migration of old code to new one?
 
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ArrayList and Vector are very similar. Both of them represent an array where you access to the elements in it through an index.
One of the main differences is that Vector class is synchronized while ArrayList is not.
ArrayList class was part of the collection framework since version 1.2 while Vector class was present since the beginning.
I think you'll find this article quite helpful.
[ March 04, 2004: Message edited by: Vicken Karaoghlanian ]
 
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic