zoukankan      html  css  js  c++  java
  • Collection接口

    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新添的方法:

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

    E get(int index);

    E set(int index, E element);

    E set(int index, E element);

    E remove(int index);

    int indexOf(Object o);

    int lastIndexOf(Object o);

    ListIterator<E> listIterator(int index);

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

    新添的方法一般都很容易理解需要注意的是listIterator方法,该方法返回一个ListIterator对象,ListIterator接口继承了Iterator接口,提供专门操作List的方法,其新添了void add()

    Obeject previous()和boolean hasPrevious(),可以反向迭代集合。

    子接口Set未添加新的方法。

    继承List接口的ArrayList类和verctor

  • 相关阅读:
    07-JSP
    06-ServletContext和ServletConfig
    05-请求转发和重定向Login
    04-session学习
    03-cookie学习
    02-servlet生命周期和doget()_dopost()方法
    01-request和respone学习
    05-jQuery案例
    04-jQuery的事件机制和动画效果
    03-jQuery操作元素
  • 原文地址:https://www.cnblogs.com/moxia1234/p/4547834.html
Copyright © 2011-2022 走看看