1//Example:
2Integer number = 15;
3System.out.println(number.getClass().getName());
4
5//This print to console the fully qualified name of the class, which for the example is:
6java.lang.Integer
7
8//If you want a more concise output, you can use instead:
9System.out.println(number.getClass().getSimpleName());
10
11//getSimpleName() give you only the name of the class:
12Integer
13
14//Printing the type of primitive variables is a bit more complex: see this
15//https://stackoverflow.com/questions/180097/dynamically-find-the-class-that-represents-a-primitive-java-type
16//for details.
1((Object) myVar).getClass().getName()
2//OR
3((Object) myInt).getClass().getSimpleName()