Proposal: Strings in Switch
Date of Original Proposal
February 27, 2009
Text of Proposal
embedded in original proposal (mail)
Add the ability to switch on string values analogous to the existing ability to switch on values of the primitive types.
Relevant Mail Discussion Threads
- Original proposal: http://mail.openjdk.java.net/pipermail/coin-dev/2009-February/000001.html
There were no replies to the original proposal on the PC mailing list.
There were some comments, but not significant discussion, when Joe posted a blog entry detailing the proposal. Of the comments, I would highlight the following
- support case-insensitive switch: another commenter pointed out this is would require
Locale-specific matching, which would complicate the proposal and implementation
- null handling: several commenters requested that a special "case null" be supported. In the current proposal, switching on a null value will cause a
NullPointerExceptionto be thrown.