Given the code fragment:
public class Foo {
public static void main (String [ ] args) {
Map<Integer, String> unsortMap = new HashMap< > ( );
unsortMap.put (10, "z");
unsortMap.put (5, "b");
unsortMap.put (1, "d");
unsortMap.put (7, "e");
unsortMap.put (50, "j");
Map<Integer, String> treeMap = new TreeMap <Integer, String> (new
Comparator<Integer> ( ) {
@Override public int compare (Integer o1, Integer o2) {return o2.compareTo
(o1); } } );
treeMap.putAll (unsortMap);
for (Map.Entry<Integer, String> entry : treeMap.entrySet () ) {
System.out.print (entry.getValue () + " ");
}
}
}
What is the result?
mvpVN
Highly Voted 6 years agoMPignaProTech
Most Recent 7 months, 2 weeks agoDarGrin
1 year, 1 month agoasdfjhfgjuaDCV
1 year, 3 months agosteefaand
1 year, 4 months agoduydn
1 year, 9 months agor1muka5
2 years, 4 months agoEden0516
2 years, 6 months agoMahdiHamdii
2 years, 6 months agoWilsonKKerll
3 years, 4 months agoThientvse
3 years, 4 months agoYasinGaber
3 years, 4 months agoakitravv
4 years, 2 months agoInnovation
5 years, 5 months agoRitesh_
5 years, 8 months ago