Java 的haspmap中若使用string数组做键值,hashcode该怎么改写,在哪里改写

[复制链接]
查看11 | 回复0 | 2010-4-9 15:30:18 | 显示全部楼层 |阅读模式
代码如下,不知道是不是这个意思public class TestMap { public static void main(String[] args) {Map map = new HashMap();
String [] a = {"a", "b", "c"};String [] b = {"d", "e", "f"};
map.put("key1", a);map.put("key2", b);//遍历整个map 里层循环 遍历每个数组里的元素 以及hashCodefor(Iterator i = map.keySet().iterator(); i.hasNext();){ String key = (String) i.next(); String str[] = map.get(key); for(int j = 0; j < str.length; j ++){
System.out.println(key + " " + str[j] + " hashCode " + str[j].hashCode()); } System.out.println();} }}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行