I have been reading this book on java about runtime type information and I am very confused about class objects and the class Class. The question maybe silly but I am kind of confused. When we normally write a class we use smaller case c for the word class. eg. public class Foo with the class name starting with upper case. so the class Class is upper case C for the class name. Now the confusion is about the class object. which is also upper case for that class. so now forexample if we have say a method in a class such as
public void countClass(Class<?> type) {
Class<?> superClass = type.getSuperclass();
}
public TypeCounter (Class<?> baseType) {
this.baseType = baseType;
}
Now in the first method what I understand is that the method countClass of type void has an argument of any type of class object? The Class referring to here is what exactly?? The class CLass? or the Class object? if it is a class object of any type why cant we just write the name of the superclass here instead of complicating things so much?
In the second method there is no type stated at all for the method TypeCounter? how does that work? and again it has a type of Class in the argument passed?
If these are referring to the Class class then what does it really mean? and if it is just the Class object then what does the class object really do in this case here?
There are classes like this:
static class PetCounter extends LinkedHasMap<Class<? extends pet>,Integer> {
....}
now the Class is what really? class Class or Class object? I'm sorry if I am confusing you with this question. But please try to answer.
Thanks in advance.
Classmeans the class called Class.