Skip to content

Commit 07e8b58

Browse files
committed
added Stream comparingByValue example
1 parent cc0c8c0 commit 07e8b58

File tree

1 file changed

+21
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)