This post originated from an RSS feed registered with Java Buzz
by Javin Paul.
Original Post: Java - ArrayList How to, Example and Tutorial
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
ArrayList is one of the most popular Collection in Java. ArrayList is an
implementation of List interface and provides ordered and index based way to
store elements. Java ArrayList is analogous to array, which is also index
based. In fact, ArrayList in Java is internally backed by array, which allows
them to get constant time performance for retrieving elements by index. Since
array is fixed length and you can not change there size, once created,
Programmers, starts using ArrayList, when they need a dynamic way to
store object, i.e. which can re-size itself. See difference
between Array and List for more differences. Though, apart from ArrayList,
there are other collection classes like Vector and LinkedList which implements
List interface and provides similar functionalities, but they are slightly
different. ArrayList is different to Vector in terms
of synchronization and speed. Most of methods in Vector requires
lock on Collection which makes them slow. By the way you can see difference
between ArrayList and Vector more differences. Similarly, LinkedList also
implements List interface but backed by linked list data structure rather than array, which means no direct access to element. When you use LinkedList, you
need to traverse till element to get access of it. Apart from that, there are
couple of more differences, which you can check on difference
between ArrayList vs LinkedList post. In this Java programming tutorial, we
will learn How to use ArrayList in Java i.e. adding, removing, accessing objects
from ArrayList andlearning key details.