Suppose we have an object called obj. We get the class of obj by: |
Class class = obj.getClass(); |
and its name by: |
String name = class.getName(); |
One can also use instanceof in following fashion: |
"foo" instanceof String |
evaluates to true, but |
( new mPoint(x,y) ) instanceof String |
evaluates to false. |