GeezerVison is showing docs.oracle.com — AbstractList (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.util
Class AbstractList<E>
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
protected int |
modCount |
The number of times this list has been structurally modified.
|
-
Constructor Summary
Constructors
| Modifier |
Constructor |
Description |
protected |
AbstractList() |
Sole constructor.
|
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods
| Modifier and Type |
Method |
Description |
boolean |
add(E e) |
Appends the specified element to the end of this list (optional
operation).
|
void |
add(int index,
E element) |
Inserts the specified element at the specified position in this list
(optional operation).
|
boolean |
addAll(int index,
Collection<? extends E> c) |
Inserts all of the elements in the specified collection into this
list at the specified position (optional operation).
|
void |
clear() |
Removes all of the elements from this list (optional operation).
|
boolean |
equals(Object o) |
Compares the specified object with this list for equality.
|
abstract E |
get(int index) |
Returns the element at the specified position in this list.
|
int |
hashCode() |
Returns the hash code value for this list.
|
int |
indexOf(Object o) |
Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
|
Iterator<E> |
iterator() |
Returns an iterator over the elements in this list in proper sequence.
|
int |
lastIndexOf(Object o) |
Returns the index of the last occurrence of the specified element
in this list, or -1 if this list does not contain the element.
|
ListIterator<E> |
listIterator() |
Returns a list iterator over the elements in this list (in proper
sequence).
|
ListIterator<E> |
listIterator(int index) |
Returns a list iterator over the elements in this list (in proper
sequence), starting at the specified position in the list.
|
E |
remove(int index) |
Removes the element at the specified position in this list (optional
operation).
|
protected void |
removeRange(int fromIndex,
int toIndex) |
Removes from this list all of the elements whose index is between
fromIndex, inclusive, and toIndex, exclusive.
|
E |
set(int index,
E element) |
Replaces the element at the specified position in this list with the
specified element (optional operation).
|
List<E> |
subList(int fromIndex,
int toIndex) |
Returns a view of the portion of this list between the specified
fromIndex, inclusive, and toIndex, exclusive.
|
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toString
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArray
-
-
Method Detail
-
add
public 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.
This implementation calls add(size(), e).
Note that this implementation throws an
UnsupportedOperationException unless
add(int, E) is overridden.
- Specified by:
add in interface Collection<E>
- Specified by:
add in interface List<E>
- Overrides:
add in class AbstractCollection<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
-
clear
public void clear()
Removes all of the elements from this list (optional operation).
The list will be empty after this call returns.
This implementation calls removeRange(0, size()).
Note that this implementation throws an
UnsupportedOperationException unless remove(int
index) or removeRange(int fromIndex, int toIndex) is
overridden.
- Specified by:
clear in interface Collection<E>
- Specified by:
clear in interface List<E>
- Overrides:
clear in class AbstractCollection<E>
- Throws:
UnsupportedOperationException - if the clear operation
is not supported by this list
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|