import java.util.* ;
class Employee implements Comparator {
public int compare (Object a, Object b) {
int k ;
String aStr, bStr ;
aStr = (String) a ;
bStr = (String) b ;
k = aStr.compareTo(bStr) ;
if (k == 0)
return aStr.compareTo(bStr) ;
else
return k ;
}
}
public class TestDemo {
public static void main (String args[]) {
TreeMap tm = new TreeMap (new Employee()) ;
tm.put("Z、张三", new Double(3534.34)) ;
tm.put("L、李四", new Double(126.22)) ;
tm.put("W、王五", new Double(1578.40)) ;
tm.put("Z、赵六", new Double(99.62)) ;
tm.put("S、孙七", new Double(-29.08)) ;
Set set = tm.entrySet() ;
Iterator itr = set.iterator() ;
while (itr.hasNext()) {
Map.Entry me = (Map.Entry) itr.next() ;
System.out.print(me.getKey() + ":") ;
System.out.println(me.getValue()) ;
}
System.out.println() ;
double balance = ((Double) tm.get("Z、张三")).doubleValue() ;
tm.put("Z、张三", new Double(balance + 2000)) ;
System.out.println("张三最新的资金数为:" + tm.get("Z、张三")) ;
}
}