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

394 Upvotes

279 comments sorted by

View all comments

Show parent comment

2

u/vegan_antitheist Aug 05 '25

How is this helpful? We already have java.util.function.Function and why would you want a mutable wrapper?

2

u/Great-Ad-799 Aug 06 '25

Just showing how it can be done, not saying that’s the only/best way. Lambdas + functional interfaces make it super clean though.

2

u/gazeciaz Aug 06 '25

How can you find all possible strategies when you use java function? In pretty big codebase it will list thousands of occurrences. This is the pretty good reason to have separated interface.

1

u/vegan_antitheist Aug 06 '25

Ok, sure. Sometimes, a custom interface is better, even if it foes the same as an existing one. And you can extend Function. But I still don't get the mutable wrapper type.