The above answers (suggesting getClass() and instanceof) are quite correct.
But, as this is the beginner forum, I thought I'd add a comment on use and misuse of these features. Java
is an object-oriented language (some would say not 100% so, but...). One therefore has powerful features like polymorphism
available, to make objects of different types behave differently when sent the same message (method call). One should use those object-oriented features as much as possible.
It is usually bad practice to write code that conditionalises (if, switch etc.) on the type of an object. As much as possible, this should be replaced by something more object-oriented.
It's not a hard-and-fast rule. Although some Ranchers may disagree, I favour pragmatism. If a particular problem can be solved much quicker by using instanceof than by refactoring to use polymorphism, then it may be OK to use instanceof. But don't get too much into the habit.
If you were thinking of using getClass() or instanceof in an "if" or "switch" statement, you should
probably go back and revisit your design.