Skip to content

Commit 640d62b

Browse files
committed
added StreamDemo7.java
1 parent dd6cd97 commit 640d62b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package java8.stream;
2+
3+
import java.util.ArrayList;
4+
import java.util.Comparator;
5+
import java.util.List;
6+
7+
public class StreamDemo7
8+
{
9+
public static void main(String[] args)
10+
{
11+
List<Integer> list=new ArrayList<>();
12+
list.add(5);
13+
list.add(2);
14+
list.add(4);
15+
list.add(1);
16+
list.add(3);
17+
18+
System.out.println("Ascending order");
19+
list.stream().sorted().forEach(System.out::println);
20+
System.out.println("Descending order");
21+
list.stream().sorted(Comparator.reverseOrder()).forEach(System.out::println);
22+
}
23+
}

0 commit comments

Comments
 (0)