diff --git a/src/main/java/com/zeekling/cn/map/sortedmap/HeadMap.java b/src/main/java/com/zeekling/cn/map/sortedmap/HeadMap.java new file mode 100644 index 0000000..db254a6 --- /dev/null +++ b/src/main/java/com/zeekling/cn/map/sortedmap/HeadMap.java @@ -0,0 +1,19 @@ +package com.zeekling.cn.map.sortedmap; + +import java.util.SortedMap; +import java.util.TreeMap; + +public class HeadMap { + + public static void main(String[] args) { + SortedMap mp = new TreeMap<>(); + mp.put("One", "Geeks"); + mp.put("Two", "For"); + mp.put("Three", "Geeks"); + mp.put("Four", "Code"); + mp.put("Five", "It"); + // 返回键小于H的映射 + System.out.print(mp.headMap("H")); + } + +}