I am trying to call a method which takes a list of Interface with a list of Enum (which implements Interface). This gives the following compile error:
The method method(List<Interface>) in the type Class is not applicable for the arguments (List<Enum>)
This is the interface:
public interface Interface {
}
This is the enum that implements the interface:
public enum Enum implements Interface {
}
This is the calling class:
import java.util.ArrayList;
import java.util.List;
public class Class {
public static void method(List<Interface> list){
}
public static void main(String[] args) {
List <Enum> enumList = new ArrayList<Enum>();
method(enumList); //This line gives the compile error.
}
}
Why is there a compile error? To me it seems that it should work because the Enum implements that interface.