I try to understand what the Object.getClass()
method does.
The documentation says that it \"returns the runtime class of an object.\" That explanation
Every class you write has a lot of metadata. That metadata consists of the class name, its fields, its methods, its base classes, the interfaces it implements, and so on.
Sometimes you may need to access that metadata from your code at runtime.
In order to do so, you can take any object and call its getClass()
method. You will receive a Class
object that will contain the above metadata.