generics - What does Map<?, ?> mean in Java? -
what map<?, ?>
mean in java?
i've looked online can't seem find articles on it.
edit : found on mp3 duration java
?
indicates placeholder in value not interested in (a wildcard):
hashmap<?, ?> foo = new hashmap<integer, string>();
and since ?
wildcard, can skip , still same result:
hashmap foo = new hashmap<integer, string>();
but can used specify or subset generics used. in example, first generic must implement serializable interface.
// fail because httpservletrequest not implement serializable hashmap<? extends serializable, ?> foo = new hashmap<httpservletrequest, string>();
but it's better use concrete classes instead of these wildcards. should use ?
if know doing :)
Comments
Post a Comment