Enum initialization method gives NullPointerException

I have a few Enums with some Strings for creating MySQL tables. When I try to access one, it throws a NullPointerException.
See this screenshot:


Does anybody know why this is happening?

You’re accessing an enum constant from its constructor parameter. The constructor is executed during the creation of the object that is going to be assigned to the enum constant, and before that object is assigned to the field storing the enum constant. Therefore, accessing the name property of an uninitialized object gives an NPE.

1 Like

Thanks, this works!
I first thought this wasn’t the case because when I removed it in one, it still didn’t work. I had to remove it in all enums apparently.