我想查找Integer
值Hashtable
中的最大值。有沒有快速有效的方法來實現這一目標?JAVA哈希表查找最大值
這是我的代碼...
Hashtable<String,Integer> h = new Hashtable<String,Integer>();
h.add("a",1);
h.add("b",5);
h.add("c",3);
h.add("d",5);
h.add("e",2);
h.add("f",1);
int max = ???;
我需要找到最大值,這在上面的例子中是5
。 Hashtable
將一直很小,平均少於100個條目。
遍歷散列表? – iluxa 2011-03-09 00:23:56
非常感謝球員 – 2011-03-09 00:42:47