Relative Content

Tag Archive for switch-statement

What is the benefit of switching on Strings in Java 7?

When I was starting to programme in Java, the fact that switch statements didn’t take strings frustrated me. Then on using Enums, I realised the benefits that you get with them rather than passing around raw values — type safety (which brings easier refactoring) & also clarity to other developers.

How to shorten the case statement from hades? [duplicate]

This question already has answers here: Refactoring Switch Statements and is there any real use for Switch Statements at all? (7 answers) Closed 10 years ago. I’m refactoring code and have reached a horribly gigantic switch statement. Every single API method available to end users is represented as an enum and we have a switch […]

How to shorten the case statement from hades? [duplicate]

This question already has answers here: Refactoring Switch Statements and is there any real use for Switch Statements at all? (7 answers) Closed 10 years ago. I’m refactoring code and have reached a horribly gigantic switch statement. Every single API method available to end users is represented as an enum and we have a switch […]