Hi johal,
When to use a Vector and when to use a List -- that would make for an interesting lesson.
I occasionally hear from developers who feel that Vector should never be used and that it will eventually be deprecated. However, the fact that Sun has retrofitted Vector to make it part of the Collections framework (including support for generics) appears to refute this claim.
My Parser/HTMLParser example in the second lesson is based on Vector instead of List. Why? I've used the Vector class since long before the Collections framework debuted. Some habits are hard to break.
In hindsight, the example would probably have been better off using List instead of Vector. As the example stands, there is no reason (apart from needing to create an object in HTMLParser's constructor so that I can demonstrate the problem of bypassing that constructor) why HTMLParser has to create its own Vector. Parser could create the Vector and make it accessible to HTMLParser (or any subclass). But if I did that, I wouldn't be demonstrating the subclass-constructor-bypass problem.
However, if List were used, it would make sense for the example to refer to List in Parse, to have each subclass constructor create its own List implementation (such as an ArrayList or a LinkedList), and to have the parse() methods return a List.
What's done is done. I'm interesting in hearing different viewpoints on the Vector versus List debate. Is it wrong to use Vector? When should Vector be used and when should List be used?
Jeff |