java util arrayslist code example

Example 1: what is arraylist

Size is dynamic
Only supports objects
not syncronized
array based class

Example 2: java api add

boolean add(E e)

Appends the specified element to the end of this list (optional operation).

Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.

Specified by:
    add in interface Collection<E>
Parameters:
    e - element to be appended to this list
Returns:
    true (as specified by Collection.add(E))
Throws:
    UnsupportedOperationException - if the add operation is not supported by this list
    ClassCastException - if the class of the specified element prevents it from being added to this list
    NullPointerException - if the specified element is null and this list does not permit null elements
    IllegalArgumentException - if some property of this element prevents it from being added to this list

Tags:

Misc Example