Java proposal would add exception case to switch

Java proposal would add exception case to switch

The readability, maintainability, and usability of switch statements and expressions in Java would be improved by a proposal to allow exceptions to be handled in the switch block.

The current OpenJDK proposal, “Exception handling in switch (Preview),” would be part of the Standard Edition of Java, although no specific version Java SE has been designated yet as the recipient. Specifically, the proposal calls for enhancing switch so that exceptions thrown by the selector (the e in switch (e) …) can be handled in the switch block.

Goals of the plan, which was created January 12 and updated April 19, include improving readability and maintainability by allowing switch to concisely handle all possible outcomes of evaluating the selector, and streamlining the use of APIs that throw checked exceptions, when used by the selector of a switch statement or expression.

To read this article in full, please click here

0Shares