package HashMapDemo;
import java.awt.RenderingHints.Key;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import javax.swing.JComboBox.KeySelectionManager;
public class HashSetDemp {
public static void main(String[] args) {
Map countries=new HashMap();
countries.put("CN", "中国");
countries.put("US", "美国");
countries.put("RS", "俄国");
System.out.println("国家总数量"+countries.size());
System.out.println("Cn对应的国家:"+countries.get("CN"));
System.out.println(countries.keySet());
System.out.println(countries.values());
Set keys =countries.keySet();
Iterator itor=keys.iterator();
while (itor.hasNext()){
String key=(String)itor.next();
String valueString=(String )countries.get(key);
System.out.println(key+"--"+valueString);
}
}
}
HashSet简单用法
最新推荐文章于 2023-08-06 17:35:40 发布