What is the difference between A and A<? extends B>?

后端 未结 4 1884
借酒劲吻你
借酒劲吻你 2020-12-23 10:57

I am a new java learner. Recently I was reading Generic programming and got my self confused with this...

A and A
         


        
4条回答
  •  暖寄归人
    2020-12-23 11:11

    ? is what is called a wildcard. It means anything that extends B.

    When you write List, your List can contains only elements of type T.

    When you write List, your List can contains any element that extends String

    I hope I'm clear, since these concepts are complicated.

提交回复
热议问题