java check type of variable code example
Example 1: get type of variable java
((Object) myVar).getClass().getName()
//OR
((Object) myInt).getClass().getSimpleName()
Example 2: get type java
a.getClass().getName()
Example 3: java typeof
Object obj = null;
obj = new ArrayList<String>();
System.out.println(obj.getClass());
obj = "dummy";
System.out.println(obj.getClass());
obj = 4;
System.out.println(obj.getClass());