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

4

u/Polygnom Aug 03 '25

I said "kinda" for a reason. You get a couple things with sealed types you dont get with enzms and vice versa. Biggest advantage of sealed types is that you can restrict the subset of allowed values, which you cannot with enums (there is an old JEP forcenhanced enums that would allow this, but it sees little traction).

2

u/OwnBreakfast1114 Aug 05 '25

The JEP was withdrawn because it was interacting poorly with generics. https://www.reddit.com/r/java/comments/jl3wir/jep_301_enhanced_enums_is_withdrawn/ I was also looking forward to this one, but it's not happening any time soon.