Reputation: 15034
HttpEntity<?> requestEntity = new HttpEntity<Object>(json, headers);
I have a couple of questions here?
?
mean here. Why have they put <?>
instead of <Object>
Object
> as its type but the Class Reference taking <?
> as its type.Upvotes: 0
Views: 272
Reputation: 46408
?
-- wildcard syntax
HttpEntity<?> requestEntity = new HttpEntity<Object>(json, headers);
`HttpEntity<?>` whose element type matches anything..
Remember that if you try to add Object into requestEntity you'd get a compiler error.
requestEntity.add(new Object());//compiler error on this line as it expects `?` not an object
read about generics here
Upvotes: 1
Reputation: 41200
?
means wild card it a generic symbol. It means HttpEntity of unknown.
Upvotes: 1