public useEnums(SomeEnum a)
{
if(a.equals(SomeEnum.SOME_ENUM_VALUE))
{
...
}
...
}
When I tried to compare the two members of enum in Java like above, I wrote .equals() Looking at it
public useEnums2(SomeEnum a)
{
if(a == SomeEnum.SOME_ENUM_VALUE)
{
...
}
...
}
You can do == like this, too. I've been in Java for about 5 years, and I'm suddenly confused. I don't know what to write.
java enum
Both are grammatically correct. I use ==. It's safe when it's null.
© 2024 OneMinuteCode. All rights reserved.