Vector - obsolete collection

Inspection reports any uses of java.util.Vector or java.util.hashtable. While still supported, these classes were legacy JDK 1.2 Collection classes and should probably not be used in new development ....

I have a Java project that uses vector Everywhere and I am using JDK 8 which is the latest. I want to know if I can run this application on the latest java.

And tell me if I can use another keyword for ArrayList like Vector for new java.

+3


source to share


1 answer


First of all, although Vector

mostly deprecated ArrayList

, it is still perfectly legal to use and your project should work fine.



As noted, however, this is not recommended. The main reason for this is that all of its methods synchronized

, which are usually useless and can slow down your application significantly. Any local variable that is not shared outside the scope of the method can be replaced with ArrayList

. Method arguments, return values, and data members must be carefully checked before being replaced with ArrayList

so that you inadvertently change synchronization semantics and introduce a hard-to-find error.

+6


source







All Articles