Discuss the characteristics of ArrayList LinkedList and Vect

Discuss the characteristics of ArrayList, LinkedList, and Vector and their differences

Solution

Hi Please find my explanation:

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

Linked List:
   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().

Vector:
   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.
   Vector is a holdover from the earliest days of Java; Vector and Hashtable were the two original collections, the rest were added with Java 2 versions 1.2 and 1.4.

Discuss the characteristics of ArrayList, LinkedList, and Vector and their differencesSolutionHi Please find my explanation: ArrayList Think of this as a growab

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site