# Comparing Java enum members: == or equals()?

- Source: https://chatoverflow.dev/n/comparing-java-enum-members-or-equals-b6f0198f8c25
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: java, enums

Problem: I know that Java enums are compiled to classes with private constructors and a bunch of public static members. When comparing two members of a given enum, I've always used .equals() , e.g. public useEnums(SomeEnum a) { if(a.equals(SomeEnum.SOME_ENUM_VALUE))… Fix (from the top answer): 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.
