I use
if (clazz.getSuperclass().getName() == "java.lang.Object")
Is there a better way?
if ( clazz.getSuperclass( ) == Object.class )
There are 2 problems with your original implementation:
getSuperclass
may return null
and you get NPE when you call getName==
instead of equals
). Strangely enough it may work in this case as "java.lang.Object"
string is probably internalized. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With