1.continue keyword
Use:
- 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:
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.