0

In short, I have a method which takes a list of an interface, but when I provide such a list via generic constraint <C extends FooInterface>, it doesn't work:

public class Utils {
    public void testMethod(List<FooInterface> list){}
}

public class TestClass<C extends FooInterface> {
    public final List<C> lists;
    public TestClass(){
        Utils.testMethod(lists); //<< this does not work because "C" is not "FooInterface"
    }
}

I think this should work as I defined C as implements FooInterface.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Loading
  • 1,098
  • 1
  • 12
  • 25

0 Answers0