Monday, May 5, 2014

switch-case on String

Example of using String on switch-case statements:

        String toBeChecked = "Einstein";
        switch(toBeChecked){
            case "Einstein":
                //...
                break;
            case "Newton":
                //...
                break;
            case "Edison":
                //...
                break;
            case "Darwin":
                //...
                break;
            case "Watt":
                //...
                break;
            default:
                //...
        }


No comments:

Post a Comment