Java records used in enums
Alberto Otero Rodríguez
albest512 at hotmail.com
Fri May 21 13:51:08 UTC 2021
Hi,
I think enums in Java should be immutable. When you let the programmer change values in an enum instance, an unexpected behaviour can happen when using multiple threads as enum instances are static (singleton).
So, I was wondering why not make enums instances be defined as records instead of normal classes.
What do you think?
Regards,
Alberto.
More information about the core-libs-dev
mailing list