for (Object object : list) explination required

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srikanthbabu
    New Member
    • Jan 2011
    • 5

    for (Object object : list) explination required

    Code:
    public static void main(String[] args) {
    		
    		    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
    		     
    		    HashMap<String, String> map = new HashMap<String, String>();
    		    map.put("1", "one");
    		    map.put("2", "two");
    		    list.add(map);
    		     
    		    for (Object object : list) {
    		        HashMap<String, String> hp = (HashMap<String, String>)object;
    		           if(hp.get("2").equals("one")){
    		                   System.out.println("True");
    		       }
    		       else{
    		           System.out.println("False");
    		       }
    		   }
    
    	}
    in the above code what is the meaning of for (Object object : list)
    PLEASE GIVE AN EXPLINATION
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    This is a special form of for loop. Follow this link.

    Regards
    Dheeraj Joshi

    Comment

    Working...