APCS Java Subset

ap.java.util
Interface List

All Superinterfaces:
java.util.Collection
All Known Implementing Classes:
ArrayList, LinkedList

public interface List
extends java.util.Collection

An ordered sequence or collection. In the AB course students will be expected to understand that ArrayList and LinkedList both implement the List interface. The List interface is only used in the AB course.


Method Summary
 boolean add(java.lang.Object x)
          Append (adds) the argument to the end of this list.
 java.lang.Object get(int index)
          Returns the element at the specified position in this list.
 Iterator iterator()
          Returns an iterator over the elements in this list.
 ListIterator listIterator()
          Returns a list iterator over the elements in this list.
 java.lang.Object set(int index, java.lang.Object o)
          Replaces the element at the specified position in this list with the specified object.
 int size()
           
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

add

public boolean add(java.lang.Object x)
Append (adds) the argument to the end of this list.

Specified by:
add in interface java.util.Collection
Parameters:
x - is the element appended to this list.
Returns:
true as required by the java.util.Collection interface

get

public java.lang.Object get(int index)
Returns the element at the specified position in this list.

Parameters:
index - is the position of the element returned
Returns:
the element in this list whose position is the argument
Throws:
java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()

set

public java.lang.Object set(int index,
                            java.lang.Object o)
Replaces the element at the specified position in this list with the specified object.

Parameters:
index - is the position of the element that will be replaced
o - is the object to be stored at the specified position
Returns:
the element previously stored at the specified position
Throws:
java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()

size

public int size()
Specified by:
size in interface java.util.Collection

iterator

public Iterator iterator()
Returns an iterator over the elements in this list. The iterator returns, via next() first the element with index zero/0.

Specified by:
iterator in interface java.util.Collection
Returns:
an iterator over the elements in this list

listIterator

public ListIterator listIterator()
Returns a list iterator over the elements in this list. The list iterator returns, via next() first the element with index zero/0.

Returns:
a list iterator over the elements in this list

unofficial documentation for the APCS Java Subset