Java Generics (Wildcards)

后端 未结 6 1483
轻奢々
轻奢々 2020-11-22 10:17

I have a couple of questions about generic wildcards in Java:

  1. What is the difference between List and List

6条回答
  •  北海茫月
    2020-11-22 11:04

    Josh Bloch also has a good explanation of when to use super and extends in this google io video talk where he mentions the Producer extends Consumer super mnemonic.

    From the presentation slides:

    Suppose you want to add bulk methods to Stack

    void pushAll(Collection src);

    – src is an E producer

    void popAll(Collection dst);

    – dst is an E consumer

提交回复
热议问题