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. Comparable c=Collections.reverse(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: incompatible types: void cannot be converted to Comparable
		Comparable c=Collections.reverse(x);
		                                ^
Main.java:16: error: no suitable method found for sort(List<String>,Comparable)
		Collections.sort(x,c);
		           ^
    method Collections.<T#1>sort(List<T#1>) is not applicable
      (cannot infer type-variable(s) T#1
        (actual and formal argument lists differ in length))
    method Collections.<T#2>sort(List<T#2>,Comparator<? super T#2>) is not applicable
      (cannot infer type-variable(s) T#2
        (argument mismatch; Comparable cannot be converted to Comparator<? super T#2>))
  where T#1,T#2 are type-variables:
    T#1 extends Comparable<? super T#1> declared in method <T#1>sort(List<T#1>)
    T#2 extends Object declared in method <T#2>sort(List<T#2>,Comparator<? super T#2>)
Main.java:20: error: variable c is already defined in method main(String[])
		Comparable c=Collections.reverseOrder(x);
		           ^
Main.java:20: error: no suitable method found for reverseOrder(List<String>)
		Comparable 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>)
Main.java:21: error: no suitable method found for sort(List<String>,Comparable)
		Collections.sort(x,c);
		           ^
    method Collections.<T#1>sort(List<T#1>) is not applicable
      (cannot infer type-variable(s) T#1
        (actual and formal argument lists differ in length))
    method Collections.<T#2>sort(List<T#2>,Comparator<? super T#2>) is not applicable
      (cannot infer type-variable(s) T#2
        (argument mismatch; Comparable cannot be converted to Comparator<? super T#2>))
  where T#1,T#2 are type-variables:
    T#1 extends Comparable<? super T#1> declared in method <T#1>sort(List<T#1>)
    T#2 extends Object declared in method <T#2>sort(List<T#2>,Comparator<? super T#2>)
5 errors
stdout
Standard output is empty