As per my readings/understandings:-
Every time JVM creates an object, it also creates a java.lang.Class
object that describes the type of the object. All instances of the same class share the same Class
object.
Class<SomeClass>
is a way to represent this object, which is of type Class
and was created when any object of type SomeClass
class was created(as per above definition) and also, is associated with SomeClass
class.
But when I read below StackOverflow thread, regarding Class<?>
:-
What does Class<?> mean in Java?
it is said in the very first answer that by writing Class<?>
, we're declaring a Class
object which can be of any type. I am so confused, wouldn't this object be of type Class
regardless of what ?
is, since its an object of class Class
?
I don't understand what 'generic' is. If you have to use that term in your answer, I'd really appreciate if you can simultaneously explain that too. Thanks.