Map里面的方法
package test; import java.util.*; import java.util.Map.Entry; import javax.imageio.event.IIOReadWarningListener; import javax.security.auth.kerberos.KerberosKey; import javax.security.auth.x500.X500Principal; import privateclass.*; import java.io.*; import java.math.BigInteger; class lop { public void te() { System.out.println("yey"); } } class Animal extends lop { int num = 4; public void eat() { } } class Dog extends Animal { int num = 5; } interface kk { public void wo(); } interface dd { public void wo(); } class poue implements kk,dd{ @Override public void wo() { // TODO Auto-generated method stub } } public class Main { private static final String space_operator = " "; public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(new BufferedInputStream(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); Map<Integer, String> mp = new HashMap<Integer, String>(); mp.put(8,"zhangsan"); mp.put(9,"lisi"); mp.put(10,"wangwu"); mp.put(11,"maliu"); mp.remove(11); for(Entry<Integer, String> x : mp.entrySet()) { System.out.println(x.getKey() + " " + x.getValue()); } for(String x : mp.values()) { System.out.println(x); } List<String> list = new ArrayList<String>(); list.add("shang"); list.add("kaishi"); for(String x : list) { System.out.println(x); } Set<Integer> keySet = mp.keySet(); Iterator<Integer> it = keySet.iterator(); while(it.hasNext()) { System.out.println(mp.get(it.next())); } Set<Map.Entry<Integer, String>> entry = mp.entrySet(); Iterator<Map.Entry<Integer, String>> it2 = entry.iterator(); while(it2.hasNext()) { Entry<Integer, String> mEntry = it2.next(); System.out.println(mEntry.getValue() + " " + mEntry.getKey()); } } }