importjava.util.Collection;importjava.util.Iterator;publicclassMyList{privateintnum=0;privateMyListPointnext;publicMyList(){}voidadd(intindex,Objectelement)在列表的指定位...
import java.util.Collection;
import java.util.Iterator;
public class MyList {
private int num=0;
private MyListPoint next;
public MyList() {
}
void add(int index, Object element)
在列表的指定位置插入指定元素(可选操作)。
boolean addAll(Collection c)
添加指定 collection 中的所有元素到此列表的结尾,顺序是指定 collection 的迭代器返回这些元素的顺序(可选操作)。
boolean addAll(int index, Collection c)
将指定 collection 中的所有元素都插入到列表中的指定位置(可选操作)。
boolean contains(Object o)
如果列表包含指定的元素,则返回 true。
boolean containsAll(Collection c)
如果列表包含指定 collection 的所有元素,则返回 true。
boolean equals(Object o)
比较指定的对象与列表是否相等。
int indexOf(Object o)
返回此列表中第一次出现的指定元素的索引;如果此列表不包含该元素,则返回 -1。
int lastIndexOf(Object o)
返回此列表中最后一次出现的指定元素的索引,或如果此列表不包含索引,则返回 -1。
boolean isEmpty()
如果列表不包含元素,则返回 true。
boolean remove(Object o)
从此列表中移除第一次出现的指定元素(如果存在)(可选操作)。
boolean removeAll(Collection c)
从列表中移除指定 collection 中包含的其所有元素(可选操作)。
boolean retainAll(Collection c)
仅在列表中保留指定 collection 中所包含的元素(可选操作)。
Object set(int index, Object element)
用指定元素替换列表中指定位置的元素(可选操作)。
int size()
返回列表中的元素数。
List subList(int fromIndex, int toIndex)
返回列表中指定的 fromIndex(包括 )和 toIndex(不包括)之间的部分视图。
Object[] toArray()
返回按适当顺序包含列表中的所有元素的数组(从第一个元素到最后一个元素)。
*/
}
//本人只写了几个方法 其他的不知道咋写了,请教个位高手!
写出上面的所有方法!
展开