如何從Map中 一個一個取值呢?

利用 Iterator

HashMap hm;(假設裡面已有資料)

Iterator   it   =hm.keySet().iterator(); 


while(it.hasNext()) 

        String   key   =   (String)it.next();   //   key 
        system.out.println(key   +   "   --   "+hm.get(key))   //   value 
}


arrow
arrow
    文章標籤
    Map 取值
    全站熱搜

    cookiesp 發表在 痞客邦 留言(0) 人氣()