当前位置:网站首页>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}边栏推荐
- C语言-入门-精华版-带你走进编程(一)
- Wechat native applet cloud development learning record 01
- [set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
- Iterm2 setting
- VMware virtual machine configuration static IP
- Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
- C#课程设计之学生教务管理系统
- How to configure GDAL under idea
- Conversion between JSON and object
- P2622 关灯问题II(状态压缩 搜索)
猜你喜欢

An intern's journey to cnosdb

IP production stream is so close to me

CLion-Toolchains are not configured Configure Disable profile问题解决

数据库应用技术课程设计之商城管理系统

Oracle queries grouped by time

MAE

Wechat applet taro learning record

MAE

STM32F103 SPI (pit Diary)

Worldview satellite remote sensing image data / meter resolution remote sensing image
随机推荐
Product creation and commercial realization of chat robot (according to La Ma Bang - Dr. Wang Jingjing - speech)
Wpf: solve the problem that materialdesign:dialoghost cannot be closed
oracle中的 (+)是什么意思
Oracle insert single quotation mark
Unity one click AssetBundle
What is BFC?
Huawei switch basic configuration (telnet/ssh login)
How to clear the console password for s7700 device
Huawei s5700 switch initialization and configuration SSH and telnet remote login methods
YOLO系列 --- xml2txt脚本
MAE
C语言-入门-精华版-带你走进编程(一)
Initial unity
Oracle queries grouped by time
Haproxy+kept cluster setup 02
What is a data type? What is the use of data types?
Haproxy+kept build 01
Huawei switches are configured with SSH login remote management switches
Iterm2 setting
the installer has encountered an unexpected error installing this package