Skip to main content
9 events
when toggle format what by license comment
Jul 16, 2013 at 7:57 vote accept Jayan
Jul 17, 2013 at 2:38
Jul 16, 2013 at 7:53 comment added jwenting the only business reason among those may be the security enhancements. Technical niceties are both debatable and utterly irrelevant for business people.
Jul 16, 2013 at 5:16 comment added Giorgio What are the advantages of using strings in a switch statement instead of integer constants?
Jul 14, 2013 at 13:39 comment added Martijn Verburg String switches are not recommended practice as you're switch on an unbound domain. Switching on Enums is a typical middle ground here as you can have String like representation, but with semantic meaning. Oh and +1 for the complete answer BTW.
Jul 14, 2013 at 5:39 comment added Billy Mailman True enough. Most compilers are allowed to do a ton of optimizations that don't change semantics though, so it's often redundant to point out little things like that; I had only specifically mentioned .equals() to be explicit that case isn't ignored. Nonetheless, I've updated the wording a bit.
Jul 14, 2013 at 5:37 history edited Billy Mailman CC BY-SA 3.0
Fixed slightly incorrect bit.
Jul 14, 2013 at 5:32 comment added Stephen C Nit pick: In fact string switch operates "as if it were using the String.equals method" (from the document you linked to). In reality, the compiler is free to optimize so that String.equals is not used ... provided that the net effect is the same. (And, I'd expect that it would use String.hashcode above a certain number of switch cases.)
Jul 14, 2013 at 5:32 review First posts
Jul 14, 2013 at 9:57
Jul 14, 2013 at 5:16 history answered Billy Mailman CC BY-SA 3.0