Java using generics with lists and interfaces

后端 未结 6 1742
遇见更好的自我
遇见更好的自我 2021-01-13 11:02

Ok, so here is my problem:

I have a list containing interfaces - List a - and a list of interfaces that extend that interface: Li

6条回答
  •  走了就别回头了
    2021-01-13 11:51

    So, the rather simple solution a friend of mine found was this:

    recordKeeper.myList = (List)(List)records;
    

    This works as I understand it because it takes baby steps. List is a List, and List is a List. It might not be pretty, but it works nonetheless.

提交回复
热议问题