Java常用集合

ArrayList

实例化: ArrayList<E> list = new ArrayList<>();
增: list.add(E e)
删: list.remove(int index)
差: list.contains(Object o) //若数组包含该元素,返回true
改: set(int index, E e)
是否为空: isEmpty()
获取长度: size()

LinkedList

LinkedList<E> list = new LinkedList<>()
增: add(E e)
	addFirst()/push()链表头添加
	addLast()/offer()链表尾添加
删: remove() 删第一个元素
	remove(E e) 删除置顶元素
	pop()删除头
	poll()查询并移除第一个元素
查: get(int index) 按照下标获取元素
	peek()
长度: size()
索引 indexOf(Object o)

Set

Set<E> set = new HashSet<>();
add(E e)
contains()
equals()
isEmpty()
size()

Map

HashMap<K,V> map = new HashMap<>();
put(K,V)
containsKey(key)
containsValue(value)
get(key)
isEmpty()
remove(key)
size()
原文地址:https://www.cnblogs.com/whisperbb/p/12431469.html