Re: Null pointer exception problem
Oliver Wong wrote:
"Colin" <razael1@gmail.com> wrote in message
news:1175795265.711524.123980@w1g2000hsg.googlegroups.com...
On Mar 30, 9:23 am, Lew <l...@nospam.lewscanon.com> wrote:
Why did you choose Vector over other List implementations? Better
alternatives
have been around since 1998.
I am just starting to program in Java after years of C++, so vector
was a familiar word. I would be very interested in learning about
other types of lists. Do you have a link describing or comparing the
different available types?
http://java.sun.com/javase/6/docs/api/java/util/List.html
In Java, "List" is the name of an interface which several classes
implement (see the "all known implementing classes" list). "Vector" is the
name of a class which implements the List interface.
The basic difference between Vector and the other classes that
implement List is that historically, Vector was written before the List
interface existed. It was later retrofitted to implement that list, so you
have a lot of "duplicate" methods, like elementAt(int index) and get(int
index), the latter being part of the List API, and the former being part
of the pre-List API of Vector.
Also, all the methods in Vector and Hashtable are synchronized, an overhead
not needed in thread-local contexts. Furthermore, the Collections class can
make synchronized versions of any collection.
Sun has massive tutorials about most Java stuff.
<http://java.sun.com/docs/books/tutorial/index.html>
Collections are covvered in
<http://java.sun.com/docs/books/tutorial/collections/index.html>
<http://java.sun.com/javase/6/docs/technotes/guides/collections/index.html>
You should spend lots and lots of time in the API docs, to which Oliver
already provided one link.
<http://java.sun.com/javase/6/docs/api/>
in particular
<http://java.sun.com/javase/6/docs/api/java/util/Collection.html>
and related links will help with collections.
--
Lew