• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is vector class was deprecated after releasing of Collection Framework  RSS feed

 
Ishant Agarwal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys!!!

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...

pl help me out to clear my concept....




Regards
Ishant Agarwal
SCJP,SCWCD
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you read the API docs,
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
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!