zoukankan      html  css  js  c++  java
  • Collection


    基本功能

    boolean add(E e)

    boolean remove(Object o)

    void clear()

    boolean contains(Object o)

    boolean isEmpty()

    int size()


    注意

    collectionXxx.java使用了未经检查或不安全的操作.

    注意:要了解详细信息,请使用 -Xlint:unchecked重新编译.

    java编译器认为该程序存在安全隐患

    温馨提示:这不是编译失败,所以先不用理会,等学了泛型你就知道了

    带All的功能

    boolean addAll(Collection c)

    boolean removeAll(Collection c)

    boolean containsAll(Collection c)

    boolean retainAll(Collection c) 注:A集合对B集合取交集,获取的交集元素存储到A集合中,返回的boolean的类型的值代表的意思是A集合是否发生了改变.


    遍历功能

    Iterator<E> iterator()

    Iterator:

    public boolean hasNext() ;

    public E next() ; next方法获取的元素后指针向后移动一位


    集合转换成数组的功能

    Object[] toArray() ;


    迭代器

    * 集合是用来存储元素,存储的元素需要查看,那么就需要迭代(遍历)

    * 迭代器的使用

    Collection c = new ArrayList();

    c.add("a");

    c.add("b");

    Iterator it = c.iterator(); //获取迭代器的引用

    while(it.hasNext()) { u //集合中的迭代方法(遍历)

    System.out.println(it.next());

  • 相关阅读:
    es6小记
    CPU密集型和I/O密集型区别
    Gulp小记
    原生表单的小详解
    div无法触发blur事件解决办法
    HMTL列表详解
    Angular开发小笔记
    Angular组件生命周期钩子
    css小笔记
    HTML格式化标签
  • 原文地址:https://www.cnblogs.com/loaderman/p/6407347.html
Copyright © 2011-2022 走看看