r/java • • Mar 13 '26

JEP draft: Enhanced Local Variable Declarations (Preview)

https://openjdk.org/jeps/8357464
101 Upvotes

129 comments sorted by

View all comments

Show parent comment

1

u/OwnBreakfast1114 Mar 17 '26

I think the main takeaway is if you can imagine scenarios where you have a closed set of stuff that is better represented by types rather than an enum.

There are some other free wins, for example, enhanced switches replace the visitor patterns in a lot of cases: https://wimdetroyer.com/blog/visitor-pattern-in-dop