List 接口

List<E> 继承自 Collection<E> Collection<E> 继承自Iterable<E>

Iterable<E> 经典方法:

                 boolean hasNext(); //如果迭代有更多的元素

                 E next(); //返回迭代中的下一个元素

                 default void forEach(Consumer<? super T> action);//遍历jdk1.8

Collection<E> 经典方法:

                 int size(); //这个集合中元素的数量

                 boolean isEmpty(); //如果此集合不包含元素

                 boolean contains(Object o); //如果这个集合包含指定的元素

                 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);//从当前集合清除集合中有的元素

                 void clear(); //清除所有元素

                 default Spliterator<E> spliterator(){ //迭代

                                  return Spliterators.spliterator(this, 0);

                 }

                 default Stream<E> steam(){ //非并行

                                  return StreamSupport.stream(spliterator(), false);

                 }

                 default Stream<E> paralleStream(){ //并行流

                                  return StreamSupport.stream(spliterator(), true);

                 }

List<E> 经典方法:

                 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 addAll(int index, Collection<? extends E> c); //给定的下标添加指定的集合

                 boolean removeAll(Collection<?> c); //清除该集合中包含的

                 boolean retainAll(Collection<?> c); //移除指定的集合所不存在的元素

                 default void replaceAll(UnaryOperator<E> operator); //JDK 1.8

                 default void sort(Comparator? super E> c); //JDK 1.8

                 void clear(); //清除元素集合

                 E get(int index); //下标所对应的元素

                 E set(int index, E element); //替换指定的元素根据下标

                 void add(int index, E element); //根据下标插入元素

                 E remove(int index); //清下标所对应的元素

                 int indexOf(Object o); //对象在集合中的第一个下标

                 int lastIndexOf(Object o); //查找最后一个对象

                 List<E> subList(int fromIndex, int toIndex); //截取集合

猜你喜欢

转载自blog.csdn.net/baidu_36327010/article/details/85062035