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

HashMap<int[],string>通過考慮它們的值來映

HashMaplt;int[],stringgt; mapping integer array by considering their values(HashMaplt;int[],stringgt;通過考慮它們的值來映射整數(shù)數(shù)組)
本文介紹了HashMap<int[],string>通過考慮它們的值來映射整數(shù)數(shù)組的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

Given the following code, I get a null (what I want is "1234"). But I wish to have a map that could consider the key as equals, if the contents of int[] are equals (rather than consider that the references of int[]), how should I do it?

HashMap<int[], String> maps=new HashMap<int[], String>();
int[] i=new int[]{1,2,3};
int[] j=new int[]{1,2,3};
maps.put(i,"1234");
System.out.print(maps.get(j));

I am opened to any map that allows keeping int[] as the key (including TreeMap) and so on, with the side condition that if that does not hamper on the effectiveness of the map accessing time.

解決方案

No way to do that with arrays, because they don't override equals() and hashCode(). You should define your own class wrapping the array, which would override equals() and hashCode() or use a List<Integer> as key instead.

這篇關(guān)于HashMap&lt;int[],string&gt;通過考慮它們的值來映射整數(shù)數(shù)組的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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(將對象列表轉(zhuǎn)換為 Map)
Create a HashMap with a fixed Key corresponding to a HashSet. point of departure(用一個固定的Key對應一個HashSet創(chuàng)建一個HashMap.出發(fā)點)
HttpMessageConverter exception : RestClientException: Could not write request: no suitable HttpMessageConverter found(HttpMessageConverter 異常:RestClientException:無法寫入請求:找不到合適的 HttpMessageConverter) - IT屋-程序員
主站蜘蛛池模板: 午夜视频一区二区三区 | 日韩中文字幕网 | 成人亚洲精品 | 国产中文字幕在线 | 国产第一页在线观看 | 国产最新视频在线 | 99精品视频在线观看 | av在线免费观看网站 | 日韩二区 | 久草新在线 | 综合久久一区 | 亚洲欧美激情四射 | 动漫www.被爆羞羞av44 | www国产精 | 久久精品成人 | 国产一区二区免费 | 国产在线中文字幕 | 欧洲亚洲视频 | 一级全黄少妇性色生活免费看 | 羞羞视频网站在线观看 | 色精品视频 | 久久婷婷国产 | 国产精品91网站 | 6080亚洲精品一区二区 | 亚洲国产一区在线 | 日韩欧美专区 | 久久久久久国产一区二区三区 | 国产精品免费一区二区三区四区 | 亚洲国产精品99久久久久久久久 | 99精品免费| 91资源在线观看 | 免费在线一区二区 | 99久久久久久99国产精品免 | 国产一区二区精品在线观看 | 很很干很很日 | 国产精品成人一区二区三区夜夜夜 | 美女视频一区二区三区 | 日本午夜网| 亚洲一区二区三区国产 | 欧美日韩国产一区二区三区 | 亚洲国产精品一区在线观看 |