generics, method signatures, assignments

后端 未结 2 1209
感情败类
感情败类 2020-12-12 00:01

I thought I understood this but obviously not...

I have a method signature like so:

void doSomething(List typeAs){...}

2条回答
  •  悲哀的现实
    2020-12-12 00:49

    Try this:

     void doSomething(List> typeAs) { ... }
    

    Note the at the beginning of the line. That way doSomething accepts every List containing any TypeAs.

提交回复
热议问题