Skip to Content
0
Former Member
Feb 12, 2007 at 11:25 AM

iterate throught the hashmap

148 Views

how could i able to iterate the hashmap object and display only the object with the values "true"............

below code....is wrong...

it display all the items whether it is true / false

Set keySet=m2.entrySet();
    Iterator it=keySet.iterator();
    while(it.hasNext()){
    	Map.Entry en=(Map.Entry)it.next();
    	if(m2.containsValue("true")){
    		
    System.out.println("checking:" +en.getKey()+"="+en.getValue());
    	}
    	    }


 Map m=new HashMap();
 m.put("a","true");
 m.put("c","true");
 m.put("d","false");
 return m;