List

ListIterator

public interface ListIterator<E> extends Iterator<E> {

//override
boolean hasNext();
void remove();
E next();

/** Returns the next element inthe list.*/
boolean hasPrevious();

E previous();

int nextIndex();

int previousIndex();

void set(E e);

void add(E e);
}

List

List继承了Collection的所有方法, 且也声明了一些新的方法。Collection点击打开链接

boolean addAll(int index, Collection<? extends E> c);

/**Inserts all of the elementsin the specified collection into this list at the specifiedposition (optional operation). Shifts the element currently at thatposition (if any) and any subsequent elements to the right(increases their indices). The newelements will appear in this list inthe order that they are returned by the specified collection's iterator. The behavior of this operation is undefinedif the specified collection is modified while the operation is inprogress.  (Note that this will occur ifthe specified collection is this list, and it's nonempty.)

* 将集中c所有的元素插入List中索引为index的位置。

*/


E get(int index);

/** Returns the element at thespecified position in this list.*/


E set(int index, E element);

/** Replaces the element at thespecified position in this list with * the specified element (optionaloperation).*/


void add(int index, E element);

/** Inserts the specifiedelement at the specified position in this list (optional operation). Shifts the element currently at that position(if any) and any subsequent*elements to the right (adds one to their indices).*/


E remove(int index);

/** Removes the element at thespecified position in this list (optional operation). Shifts any subsequent elements to the left(subtracts one from their indices). Returns the element that was removed from the list.

*/


int indexOf(Object o);

/*** Returns the index of thefirst occurrence of the specified element in this list, or-1 if this listdoes not contain the element. More formally, returns thelowest index i such that(o==null ? get(i)==null :  o.equals(get(i))), or-1 if there is *no such index.*/


int lastIndexOf(Object o);

/** Returns the index of thelast occurrence of the specified element in this list, or-1 if this listdoes not contain the element.

* More formally, returns thehighest index i such that (o==null ?  get(i)==null: o.equals(get(i))), or-1 if there is no such index.*/


ListIterator<E> listIterator();

/** Returns a list iteratorover the elements in this list (in proper sequence).*/


ListIterator<E> listIterator(int index);

/** Returns a list iterator ofthe elements in this list (in proper sequence), starting at thespecified position in this list. The specified indexindicates the first element that would be returned by an initial callto{@link ListIterator#next next}. An initial call to{@link ListIterator#previous previous} would return the element with thespecified index minus one.*/


List<E> subList(int fromIndex, int toIndex);

/** Returns a list iterator ofthe elements in this list (in proper sequence), starting at thespecified position in this list. The specified indexindicates the first element that would be returned by an initial callto{@link ListIterator#next next}. An initial call to{@link ListIterator#previous previous} would return the element with thespecified index minus one.*/


//以下方法的声明覆盖了Collection的方法。
int size();
boolean isEmpty();
boolean contains(Object o);
Iterator<E> iterator();
Object[] toArray();
<T> T[] toArray(T[] a);
boolean add(E e);
boolean remove(Object o);
boolean containsAll(Collection<?> c);
boolean addAll(Collection<? extends E> c);
boolean removeAll(Collection<?> c);
boolean retainAll(Collection<?> c);
void clear();
boolean equals(Object o);
int hashCode();

额外篇:List的主要实现类有ArrayList,ArrayList点击打开链接
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值