0
What is break
4 Respuestas
+ 1
It's manly use to stop a loop.
Exemple:
for( int i = 0; i < 10; i ++) {
if (i == 3) {
break;
}
}
In this case we are suppose to loop from 0 to 10 but the break will "break" the process when i == 3.
+ 1
The BREAK also used to stop, or end the process in FOR loop, DO...WHILE loop, WHILE loop, switch case. Remember in Switch case, if you don't use break, once the value satisfies the condition, all statements after that will be executed until it hits the Break or End of the scope.
+ 1
to stop your looping
+ 1
break is used to terminate the process and jump out of the loop without considering the remaining part of the loop