Both are technically correct. If you look at the source code for .equals()
, it simply defers to ==
.
I use ==
, however, as that will be null safe.
More Related Contents:
- How to get an enum value from a string value in Java
- Map enum in JPA with fixed values?
- How can I lookup a Java enum from its String value?
- How to implement enum with generics?
- In Java, are enum types inside a class static?
- Jackson enum Serializing and DeSerializer
- Coding Conventions – Naming Enums
- Convert from enum ordinal to enum type
- How is values() implemented for Java 6 enums?
- Enum in Java. Advantages?
- Getting enum associated with int value
- What’s the best way to implement `next` and `previous` on an enum type?
- Why shouldn’t Java enum literals be able to have generic type parameters?
- Jackson databind enum case insensitive
- How to convert enum value to int?
- Use Enum type as a value parameter for @RolesAllowed-Annotation
- Enum in Hibernate, persisting as an enum
- How thread-safe is enum in java?
- Can I set enum start value in Java?
- Override valueof() and toString() in Java enum
- Pick a random value from an enum?
- Enum within an enum
- Java Enums: Two enum types, each containing references to each other?
- Java Enums and Switch Statements – the default case?
- Lambdas in the classical Operation enum example
- Java enum valueOf() with multiple values?
- Is an enum constant-specific class body static or non-static?
- Generating Enums Dynamically
- Hibernate mapping between PostgreSQL enum and Java enum
- How to define static constants in a Java enum?