Difference Between ArrayList,Vector,LinkList?

ArrayList  Think of this as a growable array. It gives you fast iteration and fast
random access. To state the obvious: it is an ordered collection (by index), but not
sorted.ArrayList now implements the new RandomAccess interface—a marker interface (meaning it has no methods)  that says, "this list supports fast (generally constant time) random access." Choose
this over a LinkedList when you need fast iteration but aren't as likely to be doing a
lot of insertion and deletion.

Vector  Vector is a holdover from the earliest days of Java; Vector and Hashtable
were the two original collections,A Vector is basically the same as an ArrayList, but Vector methods are syn- chronized for thread safety. You'll normally want to use ArrayList instead of Vector
because the synchronized methods add a performance hit you might not need. And
if you do need thread safety, there are utility methods in class Collections that can
help. Vector is the only class other than ArrayList to implement RandomAccess.

LinkedList  A LinkedList is ordered by index position, like ArrayList, except
that the elements are doubly-linked to one another. This linkage gives you new
methods (beyond what you get from the List interface) for adding and removing
from the beginning or end, which makes it an easy choice for implementing a stack
or queue. Keep in mind that a LinkedList may iterate more slowly than an ArrayList,
but it's a good choice when you need fast insertion and deletion. As of Java 5, the
LinkedList class has been enhanced to implement the java.util.Queue interface. As
such, it now supports the common queue methods: peek(), poll(), and offer().


Popular posts from this blog

Bluetooth Data Transfer Example

DeCompile .apk file on ubuntu 14.04