Is it OK to use == on enums in Java, or do I need to use .equals()? In my testing, == always works, but I\'m not sure if I\'m guarant
==
.equals()
== is generally okay, and there are advantages to both == and .equals(). I personally prefer to always use .equals() when comparing Objects, including enums. See also this discussion:
enum
Comparing Java enum members: == or equals()?