Generic list type with question mark

  • A+

I am having trouble interpreting/understanding the generic type of a Java List:

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

How is the generic type ? extends Command called, like is there a name for it? What exactly is this type? Is it a Command object? Or does this mean that it only accepts classes extending Command? What is my advantage using this sort of construct? In what Java version was this type of construct integrated?


Upper-bounded wildcards are used to relax the type-restriction of objects you can use. In this case you accept everything that extends/implements the Command type.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: