Home Java SCJP SCWCD Servlet Submit News Contact Us Site Map


Over 500 magazines for free (including Oracle Magazine)!

Yes all of them are FREE. You can subscribe to ALL of them.
Click here to apply today!

Adding elements to the Java ArrayList

1) Adding element to the end of the List


boolean add(Object element)

Adds specified element to the end of the ArrayList

2) Insert element in the middle of the ArrayList


void add(int index, Object element)
Inserts specified element into the ArrayList at given index. This method can throw IndexOutOfBoundsException if index is out of range.

3) Append elements of a Collection to ArrayList


boolean addAll(Collection c)
Appends all elements of specified Collection in order returned by the specified Collection’s Iterator.

4) Insert elements of a Collection to ArrayList

boolean addAll(int index, Collection c)
Inserts all elements of the specified collection into ArrayList at given index. This method can throw IndexOutOfBoundsException if index is out of range.

<< Java ArrayList Constructors

Search Elements from Java ArrayList >>

Home Java SCJP SCWCD Servlet Site map