Online Java Compiler By
JavaTpoint.com
//import statements import java.lang.*; public class ClassgetCanonicalNameExample1 { public static void main(String[] args) { ClassgetCanonicalNameExample1 clsobj = new ClassgetCanonicalNameExample1(); Class clsobj2 = clsobj.getClass(); // returns the canonical name of the class if it exists System.out.println("Class Canonical Name = " + clsobj2.getCanonicalName()); // get canonical name System.out.println("Class Simple Name = " + clsobj2.getSimpleName()); // get simple name } }
Output