The method getClass() in java.lang.object returns the runtime class of an object. The concept will be clear once we discuss an example.
package com.object;
public class Sample {
public Sample(){
}
public static void main(String[]args){
Sample sample = new Sample();
System.out.println("Runtime class of sample = "+sample.getClass());
}
}
Now let us see the output
Output
Runtime class of sample = class com.object.Sample
So the class name with package name is the output.
Pingback: Object class in Java | CoderPanda