map stack queue 遍历

Set<Entry<String,Object>> entrySet = map.entrySet(); 
for (Entry<String, Object> entry : entrySet) { 
Object o = entry.getValue(); 
} 
 
 
 
//JDK1.5
Map  m  =  new HashMap();  
  for   (Object o  : map.keySet()){  
          map.get(o);  
  }

JDK1.4

Map map =  new HashMap()   ;  
   
  Iterator   it   =   map.entrySet().iterator()   ;  
  while   (it.hasNext())  
  {  
  Map.Entry   entry   =   (Map.Entry)   it.next()   ;  
  Object   key   =   entry.getKey()   ;  
  Object   value   =   entry.getValue()   ;  
  } 

 

 

 

stack

while (!s.empty()) { 
                        System.out.println(s.pop()); 
                } 

 

 

 

queue

while (q.peek() != null) { 
                        System.out.println(q.poll()); 
                } 

 

你可能感兴趣的:(Queue)