Java Reflection class get canonical name
public class Main { public static void main(String args[]) throws Exception { Class<?> c = Class.forName("java.lang.String"); System.out.println("Cannonical name: "+c.getCanonicalName()); //from w w w. j av a 2 s . com c = String.class; System.out.println("Cannonical name: "+c.getCanonicalName()); c = int[].class; System.out.println("Cannonical name: "+c.getCanonicalName()); c = int.class; System.out.println("Cannonical name: "+c.getCanonicalName()); c = Class.class; System.out.println("Cannonical name: "+c.getCanonicalName()); } }