当前位置:网站首页>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}边栏推荐
- Unity2019_ Natural ambient light_ Sky box
- Worldview satellite remote sensing image data / meter resolution remote sensing image
- PIP uses image website to solve the problem of slow network speed
- 超限黑客认知
- STM32F103 SPI (pit Diary)
- A tunnel to all ports of the server
- C language - Introduction - essence Edition - take you into programming (I)
- Youyou1 of xlua knapsack system
- Huawei s5700 switch initialization and configuration SSH and telnet remote login methods
- [USACO12MAR]Cows in a Skyscraper G(状态压缩dp)
猜你喜欢

My touch screen production "brief history" 2

Transfinite hacker cognition

WorldView卫星遥感影像数据/米级分辨率遥感影像

Install cross compiler arm none liunx gnueabihf

Unity change default editor

Transplantation of freetype Library

Basic operation and process control 2

Free use until 2015 -- viz artist multi touch plug-in package

the installer has encountered an unexpected error installing this package

Iterm2 setting
随机推荐
PIP uses image website to solve the problem of slow network speed
Golang中删除字符串的最后一个字符
YOLO系列 --- xml2txt脚本
Clip Related Script
go 解析身份证
【cocos creator】获取资源uuid
Get to know unity2 for the first time
Compilation error: "not in executable format: file format not recognized"“
Golang的range
E: 无法定位软件包 ros-melodic-desktop-full
数据库应用技术课程设计之商城管理系统
P1896 [scoi2005] non aggression (shape pressure DP)
unity2019_ Input management
PostGIS space function
C#课程设计之学生教务管理系统
Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
What to do after the browser enters the URL
LwIP learning socket (application)
[cocos creator] get the resource UUID
Flex flexible box layout