Java – generic list type with question mark

See the English answer > what is PECS (producer extensions consumer super)? 11

List<? extends Command> myVar = client.performAction(actionParams);

What about generic types? Extensions command is called. Is it like having a name? What kind is it? Is it a command object? Or does this mean that it only accepts classes that extend command? What are the benefits of using this structure? What java version integrates this type of construct?

Solution

The upper bound wildcard is used to relax the type restrictions of objects that can be used In this case, you accept everything that extends / implements the command type

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>