前言
Java的LinkedHashMap和TreeMap学习笔记
继承结构
graph TD
Object --> AbstractMap
AbstractMap --> HashMap
HashMap --> LinkedHashMap
AbstractMap --> TreeMap
Map --> HashMap
Map --> SortedMap
SortedMap --> NavigableMap
NavigableMap --> TreeMap
style Object fill:#f0f8ff,stroke:#696969
style AbstractMap fill:#f0f8ff,stroke:#696969
style HashMap fill:#f0f8ff,stroke:#696969
style LinkedHashMap fill:#f0f8ff,stroke:#696969
style TreeMap fill:#f0f8ff,stroke:#696969
style Map fill:#f0f8ff,stroke:#4169e1
style SortedMap fill:#f0f8ff,stroke:#4169e1
style NavigableMap fill:#f0f8ff,stroke:#4169e1
LinkedHashMap
创建对象
1
| LinkedHashMap<Object, Object> linkedSet = new LinkedHashMap<>();
|
Map的相关方法
传送门
映射遍历
传送门
TreeMap
创建对象
1
| TreeMap<Object, Object> treeMap = new TreeMap<>();
|
创建对象并指定排序规则
1 2 3
| TreeMap<Object, Object> treeMap = new TreeMap<>((Object o1, Object o2) -> { return o1.compareTo(o2); });
|
Map的相关方法
传送门
映射遍历
传送门
完成