getclass().getname() in java code example
Example 1: java get classname
myObject.getClass().getSimpleName();
myObject.getClass().getName();
Example 2: java get class name of object
myObject.getClass().getName()
Example 3: how to use getclass in java
public static String printClassInformation(Object o){
Class<?> cl=o.getClass();
System.out.println("Name: "+cl.getSimpleName());
System.out.println("Full name: "+cl.getCanonicalName());
System.out.println("Methods: "+Arrays.toString(cl.getMethods()));
}