龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php HashMap中的keySet()和entrySet()方法

时间:2014-11-05 15:37来源:网络整理 作者:网络 点击:
分享到:
HashMap中的keySet()和entrySet()方法 [代码片段(25行)]
据说keyset 比 entrySet 效率低.

 Map<String,String> valueMap = new HashMap<String,String>
 for(String valName :valueMap.keySet())  
        {  
            String key =valName;  
            Object value = valueMap.get(valName);        
 }  

 Set<Map.Entry<String, String>> keyEntrySet = valueMap.entrySet();  
    for(Map.Entry<String, String> entry:keyEntrySet)  
    {  
        String key = entry.getKey();  
        Object value = entry.getValue();  

   }  
Map<String,String> questionsMap= new HashMap<String,String>
Iterator<Entry<String,String>> questions = questionsMap.entrySet().iterator();
 while (questions.hasNext()) {
 Entry<String, String> question = questions.next();
 question.getValue()
question.getKey()

}
//该片段来自于http://outofmemory.cn
精彩图集

赞助商链接