-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b82a90b
commit f8b3984
Showing
7 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
spring-boot-dependencies/spring-common/src/main/java/io/spring/common/LoopRetry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.spring.common; | ||
|
||
/** | ||
* @author xiaokexiang | ||
* @since 2021/8/25 | ||
* For循环break or continue | ||
*/ | ||
public class LoopRetry { | ||
|
||
public static void main(String[] args) { | ||
breakRetry(); | ||
} | ||
|
||
private static void continueRetry() { | ||
retry: | ||
for (int i = 0; i < 3; i++) { | ||
for (int j = 0; j < 5; j++) { | ||
System.out.println("j: " + j); | ||
if (j == 3) { | ||
continue retry; | ||
} | ||
} | ||
} | ||
// 最终出现3次 0,1,2,3 | ||
System.out.println("ok"); | ||
} | ||
|
||
private static void breakRetry() { | ||
retry: | ||
for (int i = 0; i < 3; i++) { | ||
for (int j = 0; j < 5; j++) { | ||
System.out.println("j: " + j); | ||
if (j == 3) { | ||
break retry; | ||
} | ||
} | ||
} | ||
// 最终出现1次 0,1,2,3 | ||
System.out.println("ok"); | ||
} | ||
} |
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.