Skip to content

Commit cc0c8c0

Browse files
committed
added StreamDemo9.java
1 parent b5c5b3c commit cc0c8c0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package java8.stream;
2+
3+
import java.util.Comparator;
4+
import java.util.LinkedHashMap;
5+
import java.util.Map;
6+
7+
public class StreamDemo9
8+
{
9+
public static void main(String[] args)
10+
{
11+
Map<Integer,String> map=new LinkedHashMap<Integer, String>();
12+
map.put(5, "five");
13+
map.put(1, "one");
14+
map.put(4, "four");
15+
map.put(3, "three");
16+
map.put(2, "two");
17+
18+
System.out.println(map); // {5=five, 1=one, 4=four, 3=three, 2=two}
19+
20+
map.entrySet().stream().sorted(Map.Entry.comparingByKey(Comparator.reverseOrder())).forEach(System.out::println);
21+
}
22+
}

0 commit comments

Comments
 (0)