java遍歷hashTable

//獲取key值html

Enumeration k = lovResults.keys();
while(k.hasMoreElements()){ 
System.out.println(k.nextElement());
}java

//獲取VALUE值app

Enumeration e = lovResults.elements();
while(e.hasMoreElements()){
System.out.println(e.nextElement());
}post


 

方式一:url

 

Map<Integer, Integer> map = new HashMap<Integer, Integer>();

for (Map.Entry<Integer, Integer> entry : map.entrySet()) {

    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());

}

方式二:spa

            StringBuffer sbuffer = new StringBuffer(600);
            for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); )
            {
              Map.Entry element = (Map.Entry) iter.next();
              String strKey = (String) element.getKey();
              String strValue = element.getValue() != null? element.getValue().toString(): null;
//              System.out.println(" strKey -->"+strKey+" strValue-->"+strValue);
                sbuffer.append(strKey+":"+strValue+";\n");
            }

 


 

Java中如何遍歷Map對象的4種方法.net

Java 實例 - 使用 Enumeration 遍歷 HashTable

Java 集合系列11之 Hashtable詳細介紹(源碼解析)和使用示例code

相關文章
相關標籤/搜索