14 videos
80 minutes
Well, once seen the for loop and the while loop, we're going to do while. This is very simple, so I'll discuss the while, we will do the same example that while, but we will do with the do while, so I mention so there is no cash, throw and you'll see that here gets to 5 passengers at the start, well now let's fill, the first car to do while, how do we do that? Well it's simple, we, do, and here we end keys,
while, and again the condition, the condition I'm going to copy, because it will do the same, while is that the number of passengers is less than seats, and passengers have them at zero, 1 and seats in zero, zero. So here, we have to do is likewise increase number of passengers, which is this right here and display it on the screen. Show on screen, here it is! .. I update, released it, here we have it again five
at the beginning, and one by one, was increasing, that difference between the while loop, and do while. While loop, first question and then executed, the loop do while always going to run first, and then is that question, but first run, what does that mean? If here to begin with, you imagine, that seats 10 passengers were already inside, and the capacity is 10, if I make a Do While loop, I'll make a mistake, because it will increase, will put a
more passenger, passengers will get 11 where there are only 10 and then the condition is not met, and continues but it did, so do while loop, have to do when you are sure that what they're always putting will make possible without mistake, because if you can not check first there occur the error. Okay! So, the first question and then while ago, and do while first makes and then asks. Okay! It is useful, it does not mean that
this loop, it is just bad there is to know when to use it, as we have seen all the loops, I'll des-comment this, that you have here Loop, what do you see? And for nested one inside the other, while, and do while, because, well once I made this video and you know all the loops, they have within Java.
About the Author
Biography: Analyst-Programmer in different languages. Tutor PREMIUM platforms recognized worldwide as CodigoFacilito. Editor Cristalab articles. My YouTube Channel is sponsored by the ANAYA and LaTostadora publisher. I like to explain in detail and give several examples for the avoidance of doubt.