• 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
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Vector vs ArrayList

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What is the main difference b/w ArrayList and Vector?

As of my knowledge- Vector is Synchronized and ArrayList is not Synchronized.

But, we can synchronize the AyyaList by using Collections.synchronizeList(ArrayList).

then what is the main difference in between these two ?
 
Ranch Hand
Posts: 449
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vector is a legacy class that is from Java 1.0 where as ArrayList introduce in Java 1.2 with the Collection Framework. The reason why Vector still exist because removing the class would result in break the client programmer’s code. You should not use Vector in new code. If you need a synchronized collection then you can use the method as you have already specified .
 
Marshal
Posts: 27365
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Muhammad says, just use ArrayList. Asking what is the "main difference" between two things is almost always pointless.

Not to mention that using a class just because it is "synchronized" is likely to lead you into problems when you assume that the word "synchronized" means more than it actually does. So yes, use ArrayList and also study more about synchronization.
 
Nicky narayan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much.
 
The only thing that kept the leeches off of me was this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic