Last active
September 1, 2016 02:45
-
-
Save Cuthmf/f61bce187010a70d100ba70ab25ca979 to your computer and use it in GitHub Desktop.
Sistema De Pontos ( Cuthmf )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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