import java.lang.*; public class ClassDemo { public static void main(String[] args) { ClassDemo c = new ClassDemo(); Class cls = c.getClass(); //Returns the canonical name of the underlying class if it exists System.out.println("Class = " + cls.getCanonicalName()); } }