We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd6cd97 commit 640d62bCopy full SHA for 640d62b
java8Tutorials/src/main/java/java8/stream/StreamDemo7.java
@@ -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