當前位置:編程學習大全網 - 編程軟體 - 如何編制地圖

如何編制地圖

@測試

公共?作廢?測試(){

比較器?com?=新?比較器()?{

@覆蓋

公共?int?比較(對象?o1,?對象?o2)?{

如果?(o1?instanceof?Stduent?& amp& amp?o2?instanceof?Stduent)?{

Stduent?e 1 =(Stduent)o 1;

Stduent?e2=(標準)O2;

回歸?e1.getResult()。compare to(E2 . get result());

}

回歸?0;

}

};

地圖?地圖?=新?TreeMap(com);

map.put(新?Stduent(99,001),?《汪峰》);

map.put(新?Stduent(69,003),?汪峰3);

map.put(新?Stduent(79,006),?《汪峰4》);

map.put(新?Stduent(89,005),?《汪峰5》);

//通過entrySet方法將Map類型轉換為Set集合。

設置?entry = map . entry set();

//將集合集轉換為列表集。

列表?列表?=新?ArrayList(entry);?

collections . reverse(list);

System.out.println("前三名是:");

為了什麽?(int?我?=?0;?我?& lt?3;?i++)?{

system . out . println(list . get(I));

}

}

}

  • 上一篇:vb上位機怎麽顯示51單片機發送的兩字節溫度值?
  • 下一篇:VC++警告:1 warning(s)
  • copyright 2024編程學習大全網