‫Hello, my friends.
‫In this video, I'm going to talk about java break and continue statements.
‫You have already seen the break statement used in an earlier tutorial in this course.
‫It was used to jump out of a switch statement.
‫The break statement can also be used to jump out of a loop.
‫Let's take an example that stops the loop when I is equal to four.
‫For example, this is a for loop int i equal to zero.
‫This is the initial condition.
‫The condition here, the stopping condition is less than ten and I plus plus this the increment and
‫the way you increase I.
‫It's bye bye.
‫Plus, +11.
‫If I is equal to four, then you need to break through this loop.
‫System that out the brand.
‫Alan are.
‫If I remove this account, this condition, let me comment it.
‫I'll get this output the numbers from 0 to 9.
‫If I command this and let me keep it.
‫This is the condition.
‫It.
‫Only prints the numbers from 0 to 3.
‫What happens?
‫Starts from zero.
‫Print out the ie equal to zero.
‫IE is not equal to four.
‫I am equal to one now.
‫It's less than ten.
‫Yes, it's equal to four.
‫No, it will print I, which is one.
‫I is increased by one now I equal to two I equal to two to less than ten.
‫No, it will continue.
‫So if I equal to equal to four, two is not equal to four.
‫So it will not execute this code and so on until reaching four.
‫I now equal to four for less than ten.
‫Yes.
‫So I will execute this code if I equal.
‫Equal to four.
‫Yes.
‫Four.
‫Equal equal to four.
‫Then break.
‫Break condition or break statement will be executed.
‫Okay.
‫This is the break.
‫This is how we break from and a loop using the break statement.
‫The Continue statement breaks one iteration in the loop if a specified condition occurs and continues
‫with the next iteration in the loop.
‫For example, this will skips the value of four.
‫If I put here, continue.
‫And Ron again.
‫You see, these are the numbers.
‫But where is number four?
‫When it reaches I equal to four for less than ten.
‫Yes, it will execute this code of block four.
‫Equal.
‫Equal to four.
‫Yes.
‫Then continue.
‫It will jumps.
‫It will jump over and not execute the system that out the print line.
‫It will go up from this point and increase by one and continue executing the code of the loop as normal
‫and the skips the execution of four.
‫Are equal to four condition, so it will not print out the full number for OC.
‫This is a very important note I should mention in order in order to understand why I will use them later
‫on in the next apps and the next projects and in complex set things, understanding complex things start
‫by understanding the simple ones.