The following code will show the canonical class name and the simple class name.
package com.personal.sof; public class GetClassOfVariable { public static void main(String[] args) { String strVar = "Hello World"; System.out.println(strVar.getClass().getCanonicalName()); System.out.println(strVar.getClass().getSimpleName()); } }
o / p:
java.lang.String String
Sabya source share