fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.stream.Collectors;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. getList().forEach(System.out::println);
  14. }
  15.  
  16. static List<String[]> getList() {
  17. return Optional.ofNullable(getListAsObjectFromSomewhere())
  18. .map(listObject -> (List<String[]>)listObject)
  19. // return in reversed order
  20. .map(list -> list.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList()))
  21. .orElse(Collections.<String[]>emptyList());
  22. }
  23.  
  24. static Object getListAsObjectFromSomewhere() {
  25. return List.of(new String[]{"1", "hi"}, new String[]{"2", "hello"});
  26. }
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:20: error: incompatible types: inference variable T has incompatible bounds
            .map(list -> list.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList()))
                                      ^
    lower bounds: Comparable<? super T>
    lower bounds: String[]
  where T is a type-variable:
    T extends Comparable<? super T> declared in method <T>reverseOrder()
Main.java:21: error: incompatible types: Object cannot be converted to List<String[]>
            .orElse(Collections.<String[]>emptyList());
                   ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
stdout
Standard output is empty