How not to use labels and continue in switch expressions

You can use labels and a continue statement within switch expressions. However, you can't jump through switch expressions by using them as follows. Here's an example:

class Planet { 
    private static long damage; 
    public void use(SingleUsePlastic plastic) { 
        myLabel:                                           // Label  
            for (...) { 
                damage += switch(plastic) { 
                    case SPOON, FORK, KNIFE : break 7;    
                    case PLATE : continue myLabel;         // NOT 
// allowed // illegal
// jump // through
// switch // expression }; } } }

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.129.90