Break and Continue Statement

 /// break Statement :

///The break statement is used to take the control out of a construct.
/// Using break in a loop causes the program to exit the loop.
void main() {
/// Example 1
// for(var i=0; i<5; i++) {
// if(i == 2) {
// break;
// }
// print("No : $i");
// }

/// Example 2
// var i = 1;
// while(i <= 10) {
// if(i%5 == 0) {
// print("The first multiple of 5 between 1 to 10 is : $i");
// break;
// }
// i++;
// }

/// continue Statement :
/// Behaving like "Next Iteration of the loop"
for(var j=0; j<5; j++) {
if(j == 2) {
continue;
}
print("No : $j");
}

/// Difference between break and continue Statement
//break Statement completely break OR Terminate the loop after that any action will not perform
//continue Statement skip the particular Iteration after that it will continue performing action
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter