check type of a variable in java code example
Example 1: get type of variable java
((Object) myVar).getClass().getName()
//OR
((Object) myInt).getClass().getSimpleName()
Example 2: 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());