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 Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. }
  14.  
  15. public static <E extends InterfaceA & InterfaceB> void method() {
  16. List<MyClass> list = new ArrayList<>();
  17.  
  18. // Cannot convert from List<MyClass> to List<E>
  19. List<E> objects = list;
  20. }
  21. }
  22.  
  23. interface InterfaceA {}
  24. interface InterfaceB {}
  25. class MyClass implements InterfaceA, InterfaceB {}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:19: error: incompatible types: List<MyClass> cannot be converted to List<E>
		List<E> objects = list;
		                  ^
  where E is a type-variable:
    E extends InterfaceA,InterfaceB declared in method <E>method()
1 error
stdout
Standard output is empty