package com.yjf.esupplier.common.test; import java.util.LinkedHashMap; import java.util.Set; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/18 13:40 */ public class LinkedHashMapDemo { /** * LinkedHashMap:是Map接口的哈希表和链表实现,具有可预知的迭代顺序由哈希表保证键的唯一性 * 由链表保证键盘的有序(存储和取出的顺序一致) */ public static void main(String[] args) { LinkedHashMap<String, String> hm = new LinkedHashMap<String, String>(); //创建并添加元素hm.put("100", "hello"); hm.put("101", "world"); hm.put("102", "java"); hm.put("103", "javaee"); hm.put("104", "android"); //遍历 Set<String> set = hm.keySet(); for (String key : set) { String value = hm.get(key); System.out.println(key + "---" + value); } } }