ArrayList - Java Examples - Java Program Sample Source Code
ArrayList - Java Examples - Java Program Sample Source Code
http://www.java-examples.com/arraylist
HOME
JAVA FUNDAMENTALS
COMMON CLASSES
JAVA.LANG
FILE AND IO
COLLECTIONS
FREE IT BOOKS
SUBMIT EXAMPLE
Virtual Server Rs.2100/cPanel/ Plesk with Full Root Access @ 99.95 Uptime SLA. Check Offers
Ctrls.com/VPS-Hosting-Servers-India
View daily updated mobile price lists, Search lowest price of any mobile phone at Mobile Price India.
ArrayList
Java ArrayList is a resizable array which implements List interface. ArrayList provides all operation defined by List interface. Internally ArrayList uses an array to store its elements. ArrayList provides additional methods to manipulate the array that actually stores the elements. ArrayList is equivalent to Vector, but ArrayList is not synchronized. Java ArrayList Capacity Capacity of an ArrayList is the size of the array used to store the list elements. It grows automatically as we add elements to it. Every time this happens, the internal array has to be reallocated. This increases the load. We can set the initial capacity of the ArrayList using following method. ArrayList arrayList = new ArrayList(); arrayList.ensureCapacity(100); Java ArrayList Iterators Java ArrayList provides two types of Iterators. 1) Iterator 2) ListIterator Iterator iterator = arrayList.iterator(); Returns object of Iterator. ListIterator listIterator = arrayList.listIterator(); Returns object of ListIterator. ListIterator listIterator = arrayList.listIterator(int startIndex); Returns object of ListIterator. The first next() method call on this ListIterator object will return the element at the specified index passed to get the ListIterator object. Iterators returned by these methods are fail-fast. That means if the list is modified after getting the Iterator by using some other means rather than Iterators own add or remove method, Iterator will throw ConcurrentModificationException. ArrayList Constructors 1) ArrayList() Creates an empty ArrayList. For example, ArrayList arrayList = new ArrayList(); 2) ArrayList(int capacity) Creates an ArrayList with specified initial capacity. For example, Get your FREE copy
Contains technology strate articles, sample code, tips and partner news, how to for developers and DBAs, more.
1 of 3
09-10-2011 23:25
http://www.java-examples.com/arraylist
ArrayList arrayList = new ArrayList(10); 3) ArrayList(Collection c) Creates an ArrayList containing elements of the collection specified. For example, ArrayList arrayList = new ArrayList(myCollection); Where myCollection is an object of the type Collection. This creates an ArrayList of elements contained in the myCollection, in the order returned by the myCollections Iterator. Java ArrayList Examples
Add an element to specified index of Java ArrayList Example Append all elements of other Collection to Java ArrayList Example Copy all elements of Java ArrayList to an Object Array Example Get Size of Java ArrayList and loop through elements Example Get Sub List of Java ArrayList Example Insert all elements of other Collection to Specified Index of Java ArrayList Example Iterate through elements Java ArrayList using Iterator Example Iterate through elements Java ArrayList using ListIterator Example Remove all elements from Java ArrayList Example Remove an element from specified index of Java ArrayList Example Replace an element at specified index of Java ArrayList Example Search an element of Java ArrayList Example Simple Java ArrayList Example Sort elements of Java ArrayList Example
Helpfull!!!
Submitted by Anonymous on Thu, 04/02/2009 - 04:00.
helpful
Submitted by Anonymous on Thu, 08/13/2009 - 12:22.
Better way
Submitted by Anonymous on Sat, 09/05/2009 - 12:12.
This content is help and serves better for any beginner to collections framework
reply
2 of 3
09-10-2011 23:25
http://www.java-examples.com/arraylist
making progress
Submitted by Anonymous on Thu, 09/24/2009 - 20:15.
Superb
Submitted by Anonymous on Wed, 10/28/2009 - 13:55.
This is really a wonderful website.It's help me great for my preparation. Regards, CT.Srinivaasan.
reply
3 of 3
09-10-2011 23:25