r/programming • u/nihathrael • Nov 04 '25
Benchmarking the cost of Java's EnumSet - A Second Look
https://www.kinnen.de/blog/enumset-benchmark/
35
Upvotes
r/programming • u/nihathrael • Nov 04 '25
View all comments
Show parent comment
1
u/Determinant Nov 06 '25
Read the Java Language Specification again carefully. That section that I linked to said that only one of them needs to be an enum in order to safely use `==`. So you can use referential equality with a random `Object` and an enum constant. The only way this can continue to compile is if enum object identity remains.
Checkmate ; )