Subtleties on java.lang.Enum
Read OriginalThe article details a subtle issue in Java's java.lang.Enum where using getClass() on an enum constant behaves differently for enums with abstract methods versus simple enums, causing an IllegalArgumentException. It explains the problem, provides a test case to reproduce it, and offers the correct solution using the getDeclaringClass() method as per the Java documentation.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser