HashMap的遍歷


1、新建一個HashMap

Map<Integer , String> notProcInfo = new HashMap<Integer , String>();

2、往HashMap中增添數據

notProcInfo.put(infoId, infoTitle);//infoId為int型,infoTitle為String型

3、遍歷HashMap

Iterator<Entry<Integer, String>> iter = notProcInfo.entrySet().iterator();
while(iter.hasNext()){
        Map.Entry<Integer, String> info= iter.next();
        int key = info.getKey();//獲取健
        String content = info.getValue();//獲取值
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM