久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

放入java HashMap時(shí)如何避免重新排序項(xiàng)目

How to avoid items being re-ordered when put into java HashMap(放入java HashMap時(shí)如何避免重新排序項(xiàng)目)
本文介紹了放入java HashMap時(shí)如何避免重新排序項(xiàng)目的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在創(chuàng)建一個(gè)新地圖并將字符串推入其中(沒什么大不了的)-但我注意到隨著地圖的增長(zhǎng),字符串正在重新排序.是否可以停止這種重新排序,以便地圖中的項(xiàng)目保留放置時(shí)的順序?

I'm creating a new Map and pushing strings into it (no big deal) -but I've noticed that the strings are being re-ordered as the map grows. Is it possible to stop this re-ordering that occurs so the items in the map retain the order the were put in with?

Map<String,String> x = new HashMap<String, String>();
x.put("a","b");
x.put("a","c");
x.put("a","d");

x.put("1","2");
x.put("1","3");
x.put("1","4");

//this shows them out of order sadly...
for (Map.Entry<String, String> entry : x.entrySet()) {
    System.out.println("IN THIS ORDER ... " + entry.getValue());
}

推薦答案

如果您關(guān)心訂單,可以使用 SortedMap.實(shí)現(xiàn)接口的實(shí)際類(至少在大多數(shù)情況下)是 樹圖.或者,LinkedHashMap 也維護(hù)它的順序,同時(shí)仍然使用基于哈希表的容器.

If you care about order, you can use a SortedMap. The actual class which implements the interface (at least for most scenarios) is a TreeMap. Alternatively, LinkedHashMap also maintains its order, while still utilizing a hashtable-based container.

這篇關(guān)于放入java HashMap時(shí)如何避免重新排序項(xiàng)目的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Convert List of Strings into Map using Java-8 Streams API(使用 Java-8 Streams API 將字符串列表轉(zhuǎn)換為 Map)
Getting data from JSON(從 JSON 獲取數(shù)據(jù))
java linkedhashmap iteration(javalinkedhashmap迭代)
Converting a list of objects to Map(將對(duì)象列表轉(zhuǎn)換為 Map)
Create a HashMap with a fixed Key corresponding to a HashSet. point of departure(用一個(gè)固定的Key對(duì)應(yīng)一個(gè)HashSet創(chuàng)建一個(gè)HashMap.出發(fā)點(diǎn))
HttpMessageConverter exception : RestClientException: Could not write request: no suitable HttpMessageConverter found(HttpMessageConverter 異常:RestClientException:無(wú)法寫入請(qǐng)求:找不到合適的 HttpMessageConverter) - IT屋-程序員
主站蜘蛛池模板: 超碰天天 | 日韩第1页| 成人欧美一区二区三区白人 | 人人干人人舔 | 欧美久久一区二区三区 | 99re热精品视频 | 久久久精品一区二区三区 | 日本一区不卡 | 久久国| 国产成人精品午夜 | 日本久久一区二区三区 | 男人的天堂在线视频 | 久久久久亚洲 | 久久久婷 | 黄色毛片免费 | 99热这里都是精品 | 亚洲一区二区三区免费 | 久久久成人动漫 | 欧美日韩中文字幕在线播放 | 日本成人中文字幕在线观看 | 欧美黄色一区 | 精品一二三| 亚洲 中文 欧美 日韩 在线观看 | 久久精品一区二区视频 | 久久精品网 | 国产精品激情 | 婷婷综合五月天 | 色婷婷av99xx | 久久久久亚洲av毛片大全 | 91精品久久久久久久久中文字幕 | 香蕉av免费 | 精品日韩一区二区三区av动图 | 国产精品高潮呻吟久久久久 | 国产一区二区自拍 | 亚州中文字幕 | 国产一区2区 | 国产一区二区三区色淫影院 | 国产精品视频在线观看 | 黄色毛片一级 | 亚洲精品粉嫩美女一区 | 日韩欧美亚洲 |