fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Flubber{
  9. public static void main(String args[])
  10. {
  11. List<String> x=new ArrayList<String>();
  12. x.add("x");
  13. x.add("xx");
  14. x.add("Xx");
  15. Comparator c=Collections.reverseOrder(x);
  16. Collections.sort(x,c);
  17. for(String s:x)
  18. System.out.println(s);
  19.  
  20. // Comparable c=Collections.reverseOrder(x);
  21. // Collections.sort(x,c);
  22. }
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:15: error: no suitable method found for reverseOrder(List<String>)
		Comparator c=Collections.reverseOrder(x);
		                        ^
    method Collections.<T#1>reverseOrder() is not applicable
      (cannot infer type-variable(s) T#1
        (actual and formal argument lists differ in length))
    method Collections.<T#2>reverseOrder(Comparator<T#2>) is not applicable
      (cannot infer type-variable(s) T#2
        (argument mismatch; List<String> cannot be converted to Comparator<T#2>))
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in method <T#1>reverseOrder()
    T#2 extends Object declared in method <T#2>reverseOrder(Comparator<T#2>)
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
stdout
Standard output is empty