You may want to look at the 'instanceof' operator -- it tells you if an object is of a given class type, and handles things like inheritance and interface implementation as well.
getClass() returns a string; you can test against the string. But that won't tell you if the object's class inherits from the class you test it against, etc.
I agree with a previous poster, though not as strongly. Trying to figure out how to do this may indicate a lack of good design, and stepping back and rethinking it is probably in order. On the other hand, if you're just trying to figure out how to do this if you ever want to, I think this is your answer. And there are legitimate programming reasons for doing this, also.