Java 集合遍历

Map: //HashMap遍历

      public static String getMapByEntry(HashMap hmap) {
            StringBuffer  keywords = new StringBuffer();
            String numStr ="";          
            //用Set对象打印结果
            Set> enterySet = hmap.entrySet();    
            
            for (Map.Entry 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

你可能感兴趣的:(学习笔记)