• 05集合03List


    1、List接口中的常用方法。

    List是Collection接口的子接口。所以List接口中有一些特有的方法。
    void add(int index, Object element)
    Object set(int index, Object element)
    Object get(int index)
    int indexOf(Object o)
    int lastIndexOf(Object o)
    Object remove(int index)
    2、迭代器迭代元素的过程中不能使用集合对象的remove方法删除元素,
    要使用迭代器Iterator的remove方法来删除元素,防止出现异常:
    ConcurrentModificationException

    3、ArrayList
    ArrayList集合初始化容量10
    扩容为原容量1.5倍。
    底层是数组。

    数组优点和缺点要能够说出来!
    另外要注意:ArrayList集合末尾增删元素效率还是可以的。

    4、链表数据结构
    第一:单向链表和双向链表数据结构要理解。
    第二:链表数据结构的优点和缺点要能够说出来。

    5、Vector:
    Vector初始化容量是10.
    扩容为原容量的2倍。
    底层是数组。
    Vector底层是线程安全的。

    怎么得到一个线程安全的List:
    Collections.synchronizedList(list);

    6、JDK5.0新特性:泛型
    第一:集合使用泛型来减少向下转型的操作。
    第二:怎么使用泛型?
    第三:怎么自定义泛型?

    7、JDK5.0新特性:
    foreach
    对数组怎么遍历?
    for(int i : arr){
    System.out.println(i);
    }
    对集合怎么遍历?
    for(String s : list){
    System.out.println(s);
    }

    8、JDK8新特性:钻石表达式
    List<String> list = new ArrayList<>();
    类型自动推断!

  • 相关阅读:
    hdu 2199 Can you solve this equation? 二分
    STL 学习代码~
    hdu 1551 Cable master 二分
    fzu 1564 Combination 组合数是否包含因数
    fafu 1079 帮冬儿忙 组合数包含因数个数
    soj 3290 Distribute The Apples I 组合数对素数取余
    fzu 2020 组合 组合数对素数取余
    hdu 1969 Pie 二分
    hdu 2141 Can you find it? 二分
    hdu 2899 Strange fuction 二分
  • 原文地址:https://www.cnblogs.com/xiaoming521/p/15840843.html
Copyright © 2020-2023  润新知