对于list这个借口,要注意的是list里的元素是有序的,可以按index存,取
package java.util;
public interface List<E> extends Collection<E> {
int size();
boolean isEmpty();
//Returns an array containing all of the elements in this list in proper sequence (from first to last element).
Object[] toArray();
<T> T[] toArray(T[] a);
//Appends the specified element to the end of this list (optional operation).
boolean add(E e);
void add(int index, E element);
boolean addAll(Collection<? extends E> c);
boolean addAll(int index, Collection<? extends E> c);
E get(int index);
E set(int index, E element);
int indexOf(Object o);
int lastIndexOf(Object o);
//Removes the first occurrence of the specified element from this list, if it is present (optional operation).
boolean remove(Object o);
E remove(int index);
boolean removeAll(Collection<?> c);
//Retains only the elements in this list that are contained in the specified collection (optional operation).
boolean retainAll(Collection<?> c);
//Returns true if this list contains the specified element.
boolean contains(Object o);
boolean containsAll(Collection<?> c);
void clear();
boolean equals(Object o);
int hashCode();
ListIterator<E> listIterator();
//Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.
ListIterator<E> listIterator(int index);
// Returns an iterator over the elements in this list in proper sequence.
Iterator<E> iterator();
//Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
List<E> subList(int fromIndex, int toIndex);
}
No comments:
Post a Comment