当前位置:网站首页>Map的实现类的顺序性
Map的实现类的顺序性
2022-07-03 08:06:00 【小朋友哈哈】
Map的实现类有:LinkedHashMap,TreeMap,HashMap
LinkedHashMap:记录添加顺序的有序性。继承自HashMap,比HashMap增加了双链表,节点中增加了前后指针,LinkedHashMap中增加了head,tail指针
TreeMap:默认升序,红黑树
HashMap:无序 ,数组+链表+红黑树
// LinkedHashMap按照插入的顺序输出结果
Map<Character,Integer> map = new LinkedHashMap<>();
map.put('c',2);
map.put('a',4);
map.put('g',3);
map.put('d',1);
// {c=2, a=4, g=3, d=1}// TreeMap按照key顺序输出结果
Map<Character,Integer> map = new TreeMap<>();
map.put('c',2);
map.put('a',4);
map.put('g',3);
map.put('d',1);
// {a=4, c=2, d=1, g=3}// HashMap 无序
Map<Character,Integer> map = new HashMap<>();
map.put('c',2);
map.put('a',4);
map.put('g',3);
map.put('d',1);
// {a=4, c=2, d=1, g=3}边栏推荐
- idea取消引用顯示效果
- [cocos creator] Click the button to switch the interface
- STM32F103 SPI (pit Diary)
- 2021-10-19
- What is a data type? What is the use of data types?
- Usage of (case, when) in PostgreSQL
- How does yarn link help developers debug NPM packages?
- haproxy+keepalived集群搭建02
- My touch screen production "brief history" 1
- E: Unable to locate package ROS melody desktop full
猜你喜欢

C语言-入门-精华版-带你走进编程(一)

Docker installs MySQL and successfully uses Navicat connection

C language - Introduction - essence Edition - take you into programming (I)

MAE

方正锐利重磅升级到12.0版本,包装印前处理更加便捷、高效!

Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does

Xlua task list youyou

Abstract classes and interfaces

the installer has encountered an unexpected error installing this package

the installer has encountered an unexpected error installing this package
随机推荐
JS regular case-
Unity XR realizes interaction (grasping, moving, rotating, transmitting, shooting) -pico
I want to do large screen data visualization application feature analysis
Storage of data
Golang json格式和结构体相互转换
JS to implement publish and subscribe
Golang 中string和int类型相互转换
tslib库的移植
数据的存储
WorldView卫星遥感影像数据/米级分辨率遥感影像
oracle 插入单引号
Huawei s5700 switch initialization and configuration SSH and telnet remote login methods
RM delete file
Haproxy+kept build 01
Maxcompute string splitting function -split_ PART
超限黑客认知
Wechat native applet cloud development learning record 01
一个实习生的CnosDB之旅
Youyou1 of xlua knapsack system
Lua framwrok framework starts