>is ArrayList better than Vec
It depends on your needs. If you need a synchronized list and it has to be compatible with Java 1.1 then Vector is an option. Otherwise, ArrayList should be preferred, and Collections.synchronizedList will give you synchronization (which ArrayList does not have by default).
>how do i change it ????
Compare the API documentation on Vector and ArrayList. That will show you everything you need to change. You may be surprised though. ;)
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
I thought the Vector data structure was old, but I could be wrong. If there is a solution that could be done in ArrayList or Vector form, I would probably choose ArrayList.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Vector is indeed old. It is kept around mainly for legacy reasons (backwards compatibility with old code) and its use it not advised in new applications.
Sadly many tutorials and beginners' books were written ages ago and only minimally updated to keep track of new developments and thus still use Vector, thus leading many people who start out in Java to learn to use something they really shouldn't.
I've been wondering for some time now why Sun didn't just deprecate Vector, which would cause compiler warnings to be thrown whenever it's used (thus deterring people away from Vector).
ArrayList is the most common replacement, though other Lists exist (such as LinkedList) for specific scenarios.
It's faster (because it's not synchronized) and fully implements the List interface (something recently backfitted to Vector as well).
Even when needing synchronization, ArrayList (in its synchronized form) should be preferred over Vector.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337