当前位置:网站首页>Collection小结
Collection小结
2022-04-21 18:22:00 【Adsh】
1.Collection是集合类的一个总的接口。Collection有两个子接口:List和Set。Map是一个接口,但是不继承Collection。
2.List接口的子类:ArrayList、LinkedList、Vector
3.Set接口的子类:TreeSet、HashSet、LinkedHashSet。
4.Map接口的子类:TreeMap、HashMap、LinkedHashMap。
5.底层实现
- ArrayList:数组
- LinkedList:链表
- Vector:数组
- TreeSet:TreeMap TreeMap:红黑树
- HashSet:HashMap HashMap:数组+链表(jdk1.7) 数组+链表+红黑树(jdk:1.8以后)
- LinkedHashSet:红黑树+链表
6.如果往TreeSet等树形存储结构中添加元素(引用对象),需要定义比较器。比较器分为外部比较器(Comparable)和内部比较器(Comparator)
7.在集合中添加元素,可以使用泛型对添加元素的类型进行约定。泛型有泛型类,泛型接口和泛型方法。有3种通配符:<?>、<? extends class>(泛型上限)、<? super class>(泛型下限)
8.HashMap中查找元素的速度比TreeMap快。
9.TreeMap存储的是Key-value值,TreeSet也是实际上是TreeMap结构,只存储key值。
版权声明
本文为[Adsh]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_21388535/article/details/105796343
边栏推荐
猜你喜欢
随机推荐
接口
ACM anniversary C language
Teach you to easily solve CSRF Cross Site Request Forgery Attack
业绩最好 C语言
初始redis基础了解
Advanced formula 48 of C language: principle of function design
Target penetration exercise 70-dc2
观测云登陆阿里云计算巢,共建ISV新生态
Composant tooltip: déterminer si tooltip est affiché en fonction du débordement de contenu
英雄出场王 C语言
Target penetration exercise 77-dc9
干货 | 谁懂这篇文,玩游戏还会卡顿?
移动平台WorkPlus集成化办公,打造企业全场景业务生态
刚拿的字节跳动offer“打水漂”
How can the manufacturing industry save itself under the crisis of insufficient personnel and broken supply chain?
干货|app自动化之如何参数化用例
Summary of mongodb user permissions
Have you replaced commit() with sharedprefrence's apply()?
Target penetration exercise 72-dc4
K-means, hierarchy, EM clustering introduction


![[daiy4] jz76 delete duplicate nodes in the linked list (recursion)](/img/d7/c8e5b575ea93ba170c994e70b4e1cb.png)





