Is vector class was deprecated after releasing of Collection Framework
Joined: Sep 09, 2011
I am working with Collection framework so while working with it I found a Vector class which implements the List interface so i get little bit confused that vector is a legacy class and it was introduced at the time of releasing java while Collection framework was introduced in java 1.2...
So the question is
Is vector class was again introduced after releasing of java 1.2...
As of the Java 2 platform v1.2, this class was retrofitted to implement the List interface, making it a member of the Java Collections Framework. Unlike the new collection implementations, Vector is synchronized.
Since your question has nothing to do with GUI, I will move it to a more appropriate forum for you. In future do take out time to CarefullyChooseOneForum
Yes, java.util.Vector is usually regarded as a legacy class.
No, it is not deprecated; if it were, it would say "deprecated" in the documentation. There is a button in the documentation which gives access to the deprecated classes.
You ought normally to use ArrayList instead of Vector, but there are a few classes which require a Vector. You can find out from the "use" button in the documentation.
I think you ought to use the Collections#synchronizedList(java.util.List) method with an ArrayList, as described in the ArrayList documentation, if you require a synchronised List, rather than Vector.
Vector has some peculiarities, eg this constructor, which many people think you shouldn't use.
It says "retrofitted to implement the Lsit interface." If you go through the documentation looking for "since 1.2" you see lots of methods to implement the List interface were added then.