Skip to content

Instantly share code, notes, and snippets.

@Cuthmf
Last active September 1, 2016 02:45
Show Gist options
  • Save Cuthmf/f61bce187010a70d100ba70ab25ca979 to your computer and use it in GitHub Desktop.
Save Cuthmf/f61bce187010a70d100ba70ab25ca979 to your computer and use it in GitHub Desktop.
Sistema De Pontos ( Cuthmf )
public static void main(String[] args) {
Map<String,Integer> map = new HashMap<>();
map.put("Maria", 900);
map.put("Joao", 1000);
map.put("Fernanda", 424);
List<Entry<String, Integer>> entries = new ArrayList<>(map.entrySet());
Collections.sort(entries, new Comparator<Entry<String, Integer>>() {
public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
return Integer.compare(o2.getValue(), o1.getValue());
}
});
try {
System.out.println("Primeiro = " + entries.get(0).getValue());
} catch (NoSuchElementException e){
System.out.println("Map está vazia");
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment