Labeled Statement block in Java?

后端 未结 4 1216
后悔当初
后悔当初 2020-11-29 11:39

I was browsing through some of the base Java objects when I found a section of code surrounded by a scan: {} block. The following code is from the toLowerCase()

4条回答
  •  野性不改
    2020-11-29 12:02

    You can set a label to break / or continue from within multiple loops deep.

    Example

     outer:
     for(int i=...){
       for(int j=..){
         ...
         break outer; // leaves both loops   
    
       } 
    
     }
    

提交回复
热议问题