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.
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.
Joined: Mar 05, 2008
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.