fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.stream.*;
  5. import java.util.function.*;
  6. import java.lang.*;
  7. import java.io.*;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone {
  11. public static void main (String[] args) throws java.lang.Exception {
  12. Integer[] unsorted = new Integer[] { 1, 2, 3, 8, 4, 5, 6, 7 };
  13. Double[] sorted = new Double[] { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8 };
  14. try {
  15. Arrays.stream(unsorted).reduce((last, curr) -> {
  16. System.out.println("check");
  17. if (((Comparable) curr).compareTo(last) < 0) {
  18. }
  19.  
  20. return curr;
  21. });
  22. System.out.println("sorted");
  23. System.out.println("unsorted");
  24. }
  25. try {
  26. Arrays.stream(sorted).reduce((last, curr) -> {
  27. System.out.println("check");
  28. if (((Comparable) curr).compareTo(last) < 0) {
  29. }
  30.  
  31. return curr;
  32. });
  33. System.out.println("sorted");
  34. System.out.println("unsorted");
  35. }
  36. }
  37. }
  38.  
Success #stdin #stdout 0.18s 320576KB
stdin
Standard input is empty
stdout
check
check
check
check
unsorted
check
check
check
check
check
check
check
sorted