java.util.List<E>
属于公共接口,因此List<String> list = new List<String>();是无法实例化的。
已知间接子类:
AbstractList <E>, AbstractSequentialList <E>, ArrayList <E>, CopyOnWriteArrayList <E>, LinkedList <E>, Stack <E>, Vector <E> 可以通过这些类来实例化。比如:
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<String>();
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract boolean |
add(E object)
Adds the specified object at the end of this List .
| ||||||||||
abstract void |
add(int location, E object)
Inserts the specified object into this List at the specified location.
| ||||||||||
abstract boolean |
addAll(Collection<? extends E> collection)
Adds the objects in the specified collection to the end of this List .
| ||||||||||
abstract boolean |
addAll(int location, Collection<? extends E> collection)
Inserts the objects in the specified collection at the specified location in this List .
| ||||||||||
abstract void |
clear()
Removes all elements from this List , leaving it empty.
| ||||||||||
abstract boolean |
contains(Object object)
Tests whether this List contains the specified object.
| ||||||||||
abstract boolean |
containsAll(Collection<?> collection)
Tests whether this List contains all objects contained in the specified collection.
| ||||||||||
abstract boolean |
equals(Object object)
Compares the given object with the List , and returns true if they represent the same object using a class specific comparison.
| ||||||||||
abstract E |
get(int location)
Returns the element at the specified location in this List .
| ||||||||||
abstract int |
hashCode()
Returns the hash code for this List .
| ||||||||||
abstract int |
indexOf(Object object)
Searches this List for the specified object and returns the index of the first occurrence.
| ||||||||||
abstract boolean |
isEmpty()
Returns whether this List contains no elements.
| ||||||||||
abstract Iterator<E> |
iterator()
Returns an iterator on the elements of this List .
| ||||||||||
abstract int |
lastIndexOf(Object object)
Searches this List for the specified object and returns the index of the last occurrence.
| ||||||||||
abstract ListIterator<E> |
listIterator(int location)
Returns a list iterator on the elements of this List .
| ||||||||||
abstract ListIterator<E> |
listIterator()
Returns a List iterator on the elements of this List .
| ||||||||||
abstract E |
remove(int location)
Removes the object at the specified location from this List .
| ||||||||||
abstract boolean |
remove(Object object)
Removes the first occurrence of the specified object from this List .
| ||||||||||
abstract boolean |
removeAll(Collection<?> collection)
Removes all occurrences in this List of each object in the specified collection.
| ||||||||||
abstract boolean |
retainAll(Collection<?> collection)
Removes all objects from this List that are not contained in the specified collection.
| ||||||||||
abstract E |
set(int location, E object)
Replaces the element at the specified location in this List with the specified object.
| ||||||||||
abstract int |
size()
Returns the number of elements in this List .
| ||||||||||
abstract List<E> |
subList(int start, int end)
Returns a List of the specified portion of this List from the given start index to the end index minus one.
| ||||||||||
abstract <T> T[] |
toArray(T[] array)
Returns an array containing all elements contained in this List .
| ||||||||||
abstract Object[] |
toArray()
Returns an array containing all elements contained in this List .
|