Package java.util
Interface List

Public Method add

abstract void add(int index, Object o)

abstract boolean add(Object o)

_INSERT_METHOD_SIGNATURE_HERE_

Description:

add(int index, Object o) method:

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.

add(Object o) method:

Inserts the specified element at the specified position in this list (optional operation).

Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Note that basic types cannot be used with this method because they are not of type object. If you want to add e.g. a float value use the Float class, see the ArrayList example below.

Example

List MyList = new ArrayList(); // ArrayList implemnts List

MyList.add(new Float(1.23f)); // create a Float-object