List
is an ordered Collection
(sometimes called a sequence).(Sets are unordered collections)Unlike sets, Lists may contain duplicate elements. In addition to the operations inherited from
Collection
, the List
interface includes operations for: - Positional Access: manipulate elements based on their numerical position in the list.
- Search: search for a specified object in the list and return its numerical position.
- List Iteration: extend
Iterator
semantics to take advantage of the list's sequential nature. - Range-view: perform arbitrary range operations on the list.
The List
interface is shown below:
public interface List extends Collection {
// Positional Access
Object get(int index);
Object set(int index, Object element);
// Optional
void add(int index, Object element);
// Optional
Object remove(int index);
// Optional
abstract boolean addAll(int index, Collection c);
// Optional // Search
int indexOf(Object o);
int lastIndexOf(Object o);
// Iteration
ListIterator listIterator();
ListIterator listIterator(int index);
// Range-view
List subList(int from, int to);
}
No comments:
Post a Comment