fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. /* Name of the class has to be "Main" only if the class is public. */
  5. class LeftSort {
  6.  
  7. private List<Sortable> list;
  8.  
  9. public <T extends Sortable> LeftSort(List<T> list) {
  10. this.list = list;
  11. }
  12.  
  13. interface Sortable {}
  14.  
  15. static class Foo implements Sortable {}
  16.  
  17. public static void main(String[] args) throws java.lang.Exception {
  18. List<Foo> list = new ArrayList<Foo>();
  19. // Initialise... blah blah.
  20.  
  21. LeftSort sorter = new LeftSort(list);
  22. }
  23. }
  24.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:13: error: incompatible types: List<T> cannot be converted to List<Sortable>
        this.list = list;
                    ^
  where T is a type-variable:
    T extends Sortable declared in constructor <T>LeftSort(List<T>)
1 error
stdout
Standard output is empty