• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

vector or arrayList

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is use of vector or arrayList which one increase performance speed
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vector access methods are synchronized so it is slightly slower.
 
Master Rancher
Posts: 4032
54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And typically the synchronization of Vector is worse than useless anyway (in the sense that it gives false confidence to people who don't really know what they're doing). And there is really, really, no reason to use Vector in the modern age unless you're forced to because you're being paid to use a badly outdated API. Even then: just say no. We'll all be happier.
 
Saloon Keeper
Posts: 24325
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Back in 2001 I used Vector, but that's because there were no Collection classes such as ArrayList. So I have a fair amount of legacy code that uses it and it's not worth the trouble to convert.

However, all my new code uses collection classes. They're more flexible and have less overhead. And, one nice thing about them is that I can slap synchronization on them at need while not being punished when I don't need it.

Vector was redefined slightly to make it more conformant with the Collection classes. This happened in Java 1.3 or 1.4, I think. But since synchronization is one of its basic defined characteristics, I wouldn't use it in new code unless it was appropriate.
 
Mike Simmons
Master Rancher
Posts: 4032
54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Back in 2001 I used Vector, but that's because there were no Collection classes such as ArrayList.


Well, ArrayList was available as part of JDK 1.2, which came out in December 1998. Prior to that it was available as part of the Collections extension that you could download separately from Sun. When these were released as part of JDK 1.2, that's also when they added some new methods to Vector to implement the new List interface.

Anyway, I agree there's often no point to updating legacy code to replace Vector with ArrayList. I just take a somewhat aggressive stand against using Vector in any new code, nowadays.
 
Ranch Hand
Posts: 1327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is CopyOnWriteArrayList from the Java Cocurrent Package in Java 5 faster than Vector and ArrayList?
 
reply
    Bookmark Topic Watch Topic
  • New Topic