迭代Map

for  ( Iterator iterator = aMap.entrySet (  ) .iterator (  ) ; iterator.hasNext (  ) ; )   {  
     Map.Entry entry =  ( Map.Entry )  iterator.next (  ) ; 
     String key =  ( String ) entry.getKey (  ) ; 
     String value =  ( String ) entry.getValue (  ) ; 
  } 




for  ( Iterator it=pairList.entrySet (  ) .iterator (  ) ; it.hasNext (  ) ;  )   {  
         Map.Entry entry =  ( Map.Entry ) it.next (  ) ; 
         Object key = entry.getKey (  ) ; 
         Object value = entry.getValue (  ) ; 
         System.out.println (  ( String ) key+" " +  ( String ) value ) ; 
 }




 
Iterator it = ssMap.keySet (  ) .iterator (  ) ; 
 while (  it.hasNext (  )   )   {  
     Foo foo =  ( Foo )  it.next (  ) ; 
     System.out.println ( ssMap.get ( foo )  ) ; 
  
  
  } 









你可能感兴趣的:(java)