Skip to content

Commit e678d64

Browse files
committed
Test.java
Test.java
1 parent faafc82 commit e678d64

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

MapSort/src/com/hmkcode/Test.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.hmkcode;
2+
3+
4+
import java.util.HashMap;
5+
import java.util.Map;
6+
7+
public class Test {
8+
public static void main(String[] args){
9+
10+
11+
Map map = new HashMap();
12+
13+
//*value Class should implements the Comparable interface
14+
//*String implements Comparable by default.
15+
16+
map.put("Z", "3");
17+
map.put("D", "4");
18+
map.put("A", "1");
19+
map.put("B", "2");
20+
map.put("F", "6");
21+
map.put("E", "5");
22+
23+
System.out.println("Unsorted Map: "+map);
24+
System.out.println("Sorted Map By Values: "+MapSort.sortByValue(map));
25+
System.out.println("Sorted Map By Keys: "+MapSort.sortByKey(map));
26+
27+
}
28+
}

0 commit comments

Comments
 (0)