SyntaxFix
Write A Post
Hire A Developer
Questions
I agree with the use of instanceof already mentioned.
instanceof
An additional benefit of using instanceof is that when used with a null reference instanceof of will return false, while a.getClass() would throw a NullPointerException.
null
false
a.getClass()
NullPointerException