java Map 遍历 Map.Entry

package com.talent.platform.demo.httpclient;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class EntryTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Map<String,Integer> map = new HashMap<String, Integer>();
map.put("name", 123);
map.put("number", 130);
Set<String> set = map.keySet();
for(String s: set){
System.out.print(s);
}
System.out.println("\n");
Set<Entry<String, Integer>> mapset = map.entrySet();
for(Entry entry: mapset){
System.out.println(entry.getKey()+"=="+entry.getValue());
}
}
}

你可能感兴趣的:(map,entry)