Determine if two Java objects are of the same class

Viewed 55558

I am attempting to do the equivalent of

if ( object1.class == object2.class )
{
    //do something
}  

which of course doesn't work, what method am I overlooking?

4 Answers
Related