From 3da2f133f94d547e330b3b7056e73b815f705c68 Mon Sep 17 00:00:00 2001 From: zeekling Date: Fri, 29 Dec 2023 21:35:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0map.headMap=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=A0=B7=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zeekling/cn/map/sortedmap/HeadMap.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/zeekling/cn/map/sortedmap/HeadMap.java 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")); + } + +} -- 2.45.2