Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Class<?> and Class<Object> in Java [duplicate]

What is the difference between Class<?> and Class<Object> in Java? AFAIK Java Erasure changes <?> to it's upper bound, which in this case would be Object anyway. So what is this for?

like image 388
alex Avatar asked May 05 '13 23:05

alex


1 Answers

the difference is that Collection<String> is not a subtype of Collection<Object>, Collection<?> is usable in place as an argument where any collection can be put

like image 138
aaronman Avatar answered Oct 05 '22 18:10

aaronman