`
sslaowan
  • 浏览: 373840 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Java 集合遍历

阅读更多

Map: //HashMap遍历

      public static String getMapByEntry(HashMap<String, Integer> hmap) {
            StringBuffer  keywords = new StringBuffer();
            String numStr ="";          
            //用Set对象打印结果
            Set<Map.Entry<String,Integer>> enterySet = hmap.entrySet();    
            
            for (Map.Entry<String, Integer> ent : enterySet) {           
                
               keywords.append(ent.getKey() + " " + ent.getValue()+ "\n");
           }            
           return keywords.toString();
           
     }

   另一种写法

   

     
     for(String key : conditions.keySet()){              
         if (key.equalsIgnoreCase("priceLowerBound")) {  
            int priceLowerBound = Integer.parseInt(conditions.get(key));  
            if (priceLowerBound > 0)  
                hql.append(" and p.price > :priceLowerBound");  
        }  
        //Other conditions omitted  
    }  

 其他参见

 http://blog.csdn.net/avius/archive/2004/07/29/55368.aspx

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics