I use
if (clazz.getSuperclass().getName() == "java.lang.Object")
Is there a better way?
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. How about
if (clazz.getSuperclass().equals(java.lang.Object.class))