[393 views]
The yield keyword in Java is added to the language since Java JDK 14, for implementing switch expression.
'yield' keyword is used to return value from a case in a switch expression. For example:-
If the switch block code is used with new form of switch label “case L ->”, the yield keyword is used to return a value in a case where there is a block of code. For example:
Note that the code after yield can be an expression that returns a value. For example:
Liked Article? Please Buy me a Tea 😭 |