📄 abstractlist.html
字号:
<PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>set</B>(int index, <A HREF="../../java/lang/Object.html">Object</A> element)</PRE><DL><DD>Replaces the element at the specified position in this list with the specified element (optional operation). <p> This implementation always throws an <tt>UnsupportedOperationException</tt>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#set(int, java.lang.Object)">set</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - index of element to replace.<DD><CODE>element</CODE> - element to be stored at the specified position.<DT><B>Returns:</B><DD>the element previously at the specified position.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>set</tt> method is not supported by this List.<DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the class of the specified element prevents it from being added to this list.<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if some aspect of the specified element prevents it from being added to this list.<DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if the specified index is out of range (<tt>index < 0 || index >= size()</tt>).</DL></DD></DL><HR><A NAME="add(int, java.lang.Object)"><!-- --></A><H3>add</H3><PRE>public void <B>add</B>(int index, <A HREF="../../java/lang/Object.html">Object</A> element)</PRE><DL><DD>Inserts the specified element 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).<p> This implementation always throws an UnsupportedOperationException.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#add(int, java.lang.Object)">add</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - index at which the specified element is to be inserted.<DD><CODE>element</CODE> - element to be inserted.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>add</tt> method is not supported by this list.<DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the class of the specified element prevents it from being added to this list.<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if some aspect of the specified element prevents it from being added to this list.<DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - index is out of range (<tt>index < 0 || index > size()</tt>).</DL></DD></DL><HR><A NAME="remove(int)"><!-- --></A><H3>remove</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>remove</B>(int index)</PRE><DL><DD>Removes the element at the specified 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.<p> This implementation always throws an <tt>UnsupportedOperationException</tt>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#remove(int)">remove</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - the index of the element to remove.<DT><B>Returns:</B><DD>the element previously at the specified position.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>remove</tt> method is not supported by this list.<DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if the specified index is out of range (<tt>index < 0 || index >= size()</tt>).</DL></DD></DL><HR><A NAME="indexOf(java.lang.Object)"><!-- --></A><H3>indexOf</H3><PRE>public int <B>indexOf</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Returns the index in this list of the first occurence of the specified element, or -1 if the list does not contain this element. More formally, returns the lowest index <tt>i</tt> such that <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>, or -1 if there is no such index.<p> This implementation first gets a list iterator (with <tt>listIterator()</tt>). Then, it iterates over the list until the specified element is found or the end of the list is reached.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#indexOf(java.lang.Object)">indexOf</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - element to search for.<DT><B>Returns:</B><DD>the index in this List of the first occurence of the specified element, or -1 if the List does not contain this element.</DL></DD></DL><HR><A NAME="lastIndexOf(java.lang.Object)"><!-- --></A><H3>lastIndexOf</H3><PRE>public int <B>lastIndexOf</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Returns the index in this list of the last occurence of the specified element, or -1 if the list does not contain this element. More formally, returns the highest index <tt>i</tt> such that <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>, or -1 if there is no such index.<p> This implementation first gets a list iterator that points to the end of the list (with listIterator(size())). Then, it iterates backwards over the list until the specified element is found, or the beginning of the list is reached.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#lastIndexOf(java.lang.Object)">lastIndexOf</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - element to search for.<DT><B>Returns:</B><DD>the index in this list of the last occurence of the specified element, or -1 if the list does not contain this element.</DL></DD></DL><HR><A NAME="clear()"><!-- --></A><H3>clear</H3><PRE>public void <B>clear</B>()</PRE><DL><DD>Removes all of the elements from this collection (optional operation). The collection will be empty after this call returns (unless it throws an exception).<p> This implementation calls <tt>removeRange(0, size())</tt>.<p> Note that this implementation throws an <tt>UnsupportedOperationException</tt> unless <tt>remove(int index)</tt> or <tt>removeRange(int fromIndex, int toIndex)</tt> is overridden.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#clear()">clear</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#clear()">clear</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>clear</tt> method is not supported by this Collection.</DL></DD></DL><HR><A NAME="addAll(int, java.util.Collection)"><!-- --></A><H3>addAll</H3><PRE>public boolean <B>addAll</B>(int index, <A HREF="../../java/util/Collection.html">Collection</A> c)</PRE><DL><DD>Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)<p> This implementation gets an iterator over the specified collection and iterates over it, inserting the elements obtained from the iterator into this list at the appropriate position, one at a time, using <tt>add(int, Object)</tt>. Many implementations will override this method for efficiency.<p> Note that this implementation throws an <tt>UnsupportedOperationException</tt> unless <tt>add(int, Object)</tt> is overridden.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#addAll(int, java.util.Collection)">addAll</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - index at which to insert the first element from the specified collection.<DD><CODE>c</CODE> - elements to be inserted into this List.<DT><B>Returns:</B><DD><tt>true</tt> if this list changed as a result of the call.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>addAll</tt> method is not supported by this list.<DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the class of an element of the specified collection prevents it from being added to this List.<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - some aspect an element of the specified collection prevents it from being added to this List.<DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - index out of range (<tt>index < 0 || index > size()</tt>).</DL></DD></DL><HR><A NAME="iterator()"><!-- --></A><H3>iterator</H3><PRE>public <A HREF="../../java/util/Iterator.html">Iterator</A> <B>iterator</B>()</PRE><DL><DD>Returns an iterator over the elements in this list in proper sequence. <p> This implementation returns a straightforward implementation of the iterator interface, relying on the backing list's <tt>size()</tt>, <tt>get(int)</tt>, and <tt>remove(int)</tt> methods.<p> Note that the iterator returned by this method will throw an <tt>UnsupportedOperationException</tt> in response to its <tt>remove</tt> method unless the list's <tt>remove(int)</tt> method is overridden.<p> This implementation can be made to throw runtime exceptions in the face of concurrent modification, as described in the specification for the (protected) <tt>modCount</tt> field.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#iterator()">iterator</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#iterator()">iterator</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>an iterator over the elements in this list in proper sequence.<DT><B>See Also: </B><DD><A HREF="../../java/util/AbstractList.html#modCount"><CODE>modCount</CODE></A></DL></DD></DL><HR><A NAME="listIterator()"><!-- --></A><H3>listIterator</H3><PRE>public <A HREF="../../java/util/ListIterator.html">ListIterator</A> <B>listIterator</B>()</PRE><DL><DD>Returns an iterator of the elements in this list (in proper sequence). This implementation returns <tt>listIterator(0)</tt>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#listIterator()">listIterator</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>an iterator of the elements in this list (in proper sequence).<DT><B>See Also: </B><DD><A HREF="../../java/util/AbstractList.html#listIterator(int)"><CODE>listIterator(int)</CODE></A></DL></DD></DL><HR><A NAME="listIterator(int)"><!-- --></A><H3>listIterator</H3><PRE>public <A HREF="../../java/util/ListIterator.html">ListIterator</A> <B>listIterator</B>(int index)</PRE><DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -