java loop structure 05_continue keyword

1.continue keyword

Use:

  1. Can only be used for looping constructs (for, while, do ... while)

continue the role:

1. The times for the end of the cycle, the cycle continues to a subsequent lying number.

continue implementation of illustration:
Here Insert Picture Description

Note: Do not write any code to break back and continue, because writing code will never be executed!

2.continue exercises

1, can continue to use divisible 5 outputs achieved between 1 and 100.

// 方案一:不使用continue来实现
for(int i = 1; i <= 100; i++) {
	if(i % 5 == 0) {
		System.out.print(i + "\t");
	}
}
// 方案二:使用continue来实现
for (int i = 1; i <= 100; i++) {
	if (i % 5 != 0) {
		continue;
	}
	System.out.print(i + "\t");
}

ps: For the latest free documentation and instructional videos, please add QQ group (627,407,545) receive.

Published 55 original articles · won praise 0 · Views 778

Guess you like

Origin blog.csdn.net/zhoujunfeng121/article/details/104642817