wood burning stoves 2.0*
The moose likes Performance and the fly likes vector or arrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "vector or arrayList " Watch "vector or arrayList " New topic
Author

vector or arrayList

kishor kalapa
Greenhorn

Joined: Jun 05, 2008
Posts: 24
Is use of vector or arrayList which one increase performance speed
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Vector access methods are synchronized so it is slightly slower.
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3001
    
    9
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.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3001
    
    9
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.
Billy Tsai
Ranch Hand

Joined: May 23, 2003
Posts: 1297
is CopyOnWriteArrayList from the Java Cocurrent Package in Java 5 faster than Vector and ArrayList?


BEA 8.1 Certified Administrator, IBM Certified Solution Developer For XML 1.1 and Related Technologies, SCJP, SCWCD, SCBCD, SCDJWS, SCJD, SCEA,
Oracle Certified Master Java EE 5 Enterprise Architect
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: vector or arrayList
 
Similar Threads
Iteration speed of Collections
Vector vs ArrayList
Difference between ArrayList and Vector
Difference between ArrayList and Vector
what is the difference between arrays,vector and Array List?