Since Java 14, switch is no longer just a statement , it’s an expression
1. Use -> instead of :
2. No break
3. Can return values
4. Use yield for block logic
I was still using the old way 😅
Sharing so you don’t miss it.
#Java#Java14#Programming#Developers#Learning
Instead of using the break keyword in every case statement, we can simply use a lambda. Learn about #lambda in switch case statements, #Java12 previewed—and #Java14 standardized—a cleaner and more efficient way to handle multiple conditions. 🚀 💻
🔗 bit.ly/3K9sP9W
Explore the evolution of switch cases in #Java! 🚀 With the introduction of lambda in switch case statements, #Java12 previewed & #Java14 standardized a cleaner and more efficient way to handle multiple conditions. 🛠️ 💻
🔗 bit.ly/3K9sP9W#SwitchCase#JavaChallenger
fui corrigir meu junior dizendo que java não suportava records e que ele tava confundindo com C# e simplesmente tomei um fecho porque ele me mostrou que já estamos no java20 e tem suporte pra record desde o java14(2020)