Java generics: wildcard<?> vs type parameter?

前端 未结 3 892
孤城傲影
孤城傲影 2020-12-04 16:59

I am refreshing my knowledge on Java generics. So I turned to the excellent tutorial from Oracle ... and started to put together a presentation for my coworkers. I came acro

3条回答
  •  再見小時候
    2020-12-04 17:01

    Both solutions are effectively the same, it's just that in the second one you are naming the wildcard. This can come handy when you want to use the wildcard several times in the signature, but want to make sure that both refer to the same type:

    static  void printObjects(List list, PrintFormat format) {
    

提交回复
热议问题