Hello, in this video we are going to cover the do while loop. So the do while loop is, you know, similar to the while loop it syntax where you have a condition and any variable that you need to set up or use, it's settled beforehand. And he saw like incrementing, or changing to what the condition might be doing or like the variable, that the condition check in is done inside. But the only difference is the do while loop will actually get run once, regardless of the condition. And then it will check for it. So you will get one actually one.
So if you need to run the code at least once, then maybe you know you might you 20 more times, like that scenario giving you in the for loop and the while loop video where you get input from the user. You want to get the input at least once if it's valid, that's fine. You know you continue with your business. But if it's not then you Keep asking for input till it is valid. So I will print this out. And you know what I'm putting a backslash n, which is the new long just to see, for to this, do while loop and create a new variable called int k will simulate the exact result and then I'll show you a little difference.
In the do while loop there is a slide. So you could do don't put the condition here, curly braces, and then you put that in the while condition at the end. Like I said, it doesn't get checked on totally one pass occurred. The condition we're gonna say 100 Hold on. So you need to send me Hold on for the do while loop and in here you put your code so system Swim dot print ln and k plus if we run it. So see if we get the do while.
So we get to walk is exactly the same. But imagine if I were to change this SSID. So if I change this to zero, I change this to zero, and I change this to a zero. And one. I didn't see only the do one run, curl. If we you know, dry run it, the for loop says in it thought I is declared n equals zero.
It says, run this loop while i is less than zero. And zero is not less than zero so it does not run. If we do the next one, same thing j is zero, while j is less than zero, run the wall j is zero. So zero is not less than zero, so it doesn't run whereas with this It says do this code, then check this condition. So while K is F Zero k zero, so it says k less zero is less than zero, which is false, so it doesn't run the code again. So that's the minute difference.
So if I were to take this step, this step further perhaps, and instead of less than zero or do less noise, to still get the exact same result. So for doing this once turn less than minus 10. Yeah, there we go. is still producing the exact same row results. So the do while loop will get run once a one path will occur, that after that pass, the condition will be checked. If that condition is still true, then you'll run another path till the condition is false.
So the only difference between the wall and the wall One Pass will always get run. After that it is exactly the same. So I'm do this to the point where we had in less than 100. And then we'll end this video. So thanks for watching. If you have any questions, feel free to reach out.
If you want to know more about the nuances and the use cases of the different loops, feel free to ask all of the source code for the loop videos and all the source code for every project that we do in this series will be on the GitHub page, and they'll be a link to that with the video. Thanks for watching, and I look forward to seeing you next awesome Java video.