r/java • • Aug 03 '25

Teach Me the Craziest, Most Useful Java Features — NOT the Basic Stuff

I want to know the WILD, INSANELY PRACTICAL, "how the hell did I not know this earlier?" kind of Java stuff that only real devs who've been through production hell know.

Like I didn't know about modules recently

393 Upvotes

279 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Aug 03 '25

I guess the @Override is needed because there is already a default apply() for enums?

2

u/shinmai_rookie Aug 04 '25

Sorry I didn't see this earlier. @Override is strictly never needed, functions are overridden the moment you create a function with the same signature (or one compatible) in a subclass, @Override only exists to show your intent to other programmers and to have the compiler ensure you are overriding something, and abort the compilation if not.

That said, the reason for the @Overrides is what the other user said: it refers to the abstract function that we are arbitrarily defining, not any default enum function.

0

u/[deleted] Aug 03 '25

[deleted] — view deleted comment

1

u/[deleted] Aug 03 '25

Right, I see it at the bottom. Thanks