三、Java基础复习----集合 Collection、List

1.容器 Java 所提供的一系列类的实例,用于在程序中存放对象 java.util

    Collection                 Interface                java

    List interface             (有序可重复)                                                  Set interface(无序不可重复) 数组

  

    public       boolean add(E e);添加一个对象到集合中dom

    public       boolean addAll(Collection<? extends E> c) ;添加一组集合到集合中spa

    public       void    clear();移除集合中全部元素对象

    public       boolean contains(Object o);集合中是否包含o对象索引

    public       boolean containsAll(Collection<?> c);集合中是否所有包含c里面的元素element

    public       boolean isEmpty();集合是没有一个元素rem

    public       Iterator<E> iterator();获取集合迭代器it

    public       boolean remove(Object o);移除集合中的oio

    public       boolean removeAll(Collection<?> c) 移除集合中全部c集合的元素

    public       boolean retainAll(Collection<?> c) 集合与c集合是否存在交集

    public       int     size();集合中元素个数

    public       Object[] toArray();集合转换成数组


 2.List   能够存储null

    extends    AbstractList<E>

    implements List<E>, RandomAccess, Cloneable, java.io.Serializable

    

    RandomAccess 用来代表其支持快速(一般是固定时间)随机访问

    public       int      indexOf(Object o)方法返回指定元素的第一个匹配项的索引在此列表中,或者-1

    public       int      lastIndexOf(Object o)方法返回指定元素的最后一个匹配项的索引在此列表中,或者-1

    pubblic      E        set(int index,E element)替换指定位置的元素

    public       List<E>  subList(int fromIndex,int toIndex) 截取子集合在fromIndex和toIndex之间

相关文章
相关标签/搜索