import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeMap;
public class setformrk {
public static void main(String[] args) {
// TODO Auto-generated method stub
TreeMap map= new TreeMap( new myComparator());
map.put( "2", "王一");
map.put( "1", "王二");
map.put( "3", "王三");
map.put( "4", "王四");
map.put( "5", "王五");
map.put( "6", "王六");
map.put( "7", "王七");
map.put( "8", "王八");
map.put( "9", "王九");
map.put( "10", "王十");
map.put( "11", "王十一");
map.put( "12", "王十二");
map.put( "13", "王十三");
map.put( "14", "王十四");
map.put( "15", "王十五");
Iterator it= map.keySet().iterator();
while(it.hasNext()) {
Object key=it.next();
System.out.println(key+ " : "+ map.get(key));
}
}
}
class myComparator implements Comparator{
@Override
public int compare(Object o1, Object o2) {
// TODO Auto-generated method stub
return Integer.parseInt((String)o2)-Integer.parseInt((String)o1);
}
}
import java.util.Iterator;
import java.util.TreeMap;
public class setformrk {
public static void main(String[] args) {
// TODO Auto-generated method stub
TreeMap map= new TreeMap( new myComparator());
map.put( "2", "王一");
map.put( "1", "王二");
map.put( "3", "王三");
map.put( "4", "王四");
map.put( "5", "王五");
map.put( "6", "王六");
map.put( "7", "王七");
map.put( "8", "王八");
map.put( "9", "王九");
map.put( "10", "王十");
map.put( "11", "王十一");
map.put( "12", "王十二");
map.put( "13", "王十三");
map.put( "14", "王十四");
map.put( "15", "王十五");
Iterator it= map.keySet().iterator();
while(it.hasNext()) {
Object key=it.next();
System.out.println(key+ " : "+ map.get(key));
}
}
}
class myComparator implements Comparator{
@Override
public int compare(Object o1, Object o2) {
// TODO Auto-generated method stub
return Integer.parseInt((String)o2)-Integer.parseInt((String)o1);
}
}