s-day04-LinkedHashMap的特点
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.inmind.map01;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
6.LinkedHashMap的特点
|
||||
hash:哈希表,它的作用去重,通过hashCode和equals
|
||||
link:链表,保证有序
|
||||
|
||||
LinkedHashMap:存取有序,没有索引,不能重复的,一个双列集合
|
||||
*/
|
||||
public class LinkedHashMapDemo05 {
|
||||
public static void main(String[] args) {
|
||||
Map<String,String> maps = new HashMap<>();
|
||||
maps.put("刘备","孙尚香");
|
||||
maps.put("吕布","貂蝉");
|
||||
maps.put("张飞","夏侯驰");
|
||||
System.out.println(maps);
|
||||
System.out.println("-------------");
|
||||
LinkedHashMap<String,String> linkedMaps = new LinkedHashMap<>();
|
||||
linkedMaps.put("吕布","貂蝉");
|
||||
linkedMaps.put("张飞","夏侯驰");
|
||||
linkedMaps.put("刘备","孙尚香");
|
||||
System.out.println(linkedMaps);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user