对集合的理解

1、Collection,Collections
Collection是一个接口,Collection给集合提供方法,比如排序

2、Collection接口有两个子接口     和Collection是兄弟关系的还有Map
List 和Set        和它为兄弟的是  HashMap,TreeMap

List有ArrayList,和LinkedList
ArrayList是连续的空间适合索引查找元素
size(),add(),remove(),get(index)

LinkedList是链表存储方式,适合插入和删除
size(),containes(),add(),remove(),addFirst(),addLast(),removeFirst(),removeLast();

HashMap
通过键值对的方式添对象
键不能同,值可以同
put(),get(),remove(),size(),keySet()返回键的集合,values()返回值得集合,containesKey,返回boolen


猜你喜欢

转载自www.cnblogs.com/wyrui/p/10591747.html