package aaa;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap.KeySetView;


import javax.security.auth.kerberos.KerberosKey;
public class Map {


public static void main(String[] args) {
// TODO Auto-generated method stub
TreeMap tm = new TreeMap(new reset());
tm.put("01","shang");
tm.put("03","S_sadness");
tm.put("02","zhang");
tm.put("04","zhao");
tm.put("06","Tom");
tm.put("08","jesson");
tm.put("09","july");
tm.put("10","anhao");
tm.put("05","jim");
tm.put("07","jack");
Set KeySet= tm.keySet();
Iterator it = KeySet.iterator();
while(it.hasNext())
{
Object key = it.next();
Object value = tm.get(key);
System.out.println(key+":"+value);
}
}


}


package aaa;


import java.util.Comparator;


public class reset implements Comparator {
public int compare(Object obj1,Object obj2){
String id1 = (String) obj1;
String id2 = (String) obj2;
return id1.compareTo(id2);
}
}



选择某种Map集合保存学号从1到15的学员的学号(键)和姓名(值)

相关文章:

  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
猜你喜欢
  • 2021-07-14
  • 2021-04-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案