I saw that definition in a protobuf generated java file:
java.util.List<? extends xxx.yyy.zzz.proto.BasicMessage.DestInfoOrBuilder> foo();
But what dose <?
and extends
mean? I can understand List<SomeClass>
I can't understand List<? extends SomeClass>
..
This is a generic declaration.
It is used to check types at compile time. You could put any object into a list, but that would make it more difficult to maintain and could cause ClassCastException
s, if not used appropriate.
<? extends xxx.yyy.zzz.proto.BasicMessage.DestInfoOrBuilder>
means "allow every class which extends DestInfoOrBuilder
".