Learn Java Tutorial for Beginners, Part 8: Do … While Loops

///Learn Java Tutorial for Beginners, Part 8: Do … While Loops

Learn Java Tutorial for Beginners, Part 8: Do … While Loops

FavoriteLoadingAdd to favorites

Get complete courses at
How to use do…while loops in Java, plus variable scope and multi-line comments. I take a look at a solution to a commonly-assigned beginner’s exercise in Java.

source

Java468x60
By |2019-11-20T00:01:15+00:00November 20th, 2019|Java Video Tutorials|34 Comments

34 Comments

  1. Jo Habib November 20, 2019 at 12:01 am - Reply

    Thank you! (Every tutorial i finish i feel i thank you very much for the lovely way you teach). I enjoy your lessons very much, Thank you <3!

  2. kodzo edem Tudzi November 20, 2019 at 12:01 am - Reply

    Instead of writing a do-while loop, i came up with this code:

    Scanner scanner= new Scanner(System.in);

    int num=0;

    while(num !=5) {

    System.out.println("Enter a number: ");
    num = scanner.nextInt();
    }

    what do you think?

  3. Ashhar Amir November 20, 2019 at 12:01 am - Reply

    Is it done on the class application? when i copy the code given in the website, it gives error

  4. redmeetingwhite November 20, 2019 at 12:01 am - Reply

    Thank you so so much!! This is the best playlist ever! I was just wondering if you have any other basic programming tasks/ questions that can help ppl learn by experience? Kind of like the one you expressed in this video? Again, thanks for everything your videos are super helpful!!

  5. Not Gay November 20, 2019 at 12:01 am - Reply

    For anyone who happens to stumble across this series and is truly new to Java, I recommend trying to make a program that can play the game 'Fizz Buzz" with as few lines of code as possible. It's not terribly hard but its good practice with logic and stuff in programming.

    My current score is 19 lines of code 😀

  6. Kelley November 20, 2019 at 12:01 am - Reply

    Thank you John once again

  7. Fizmox November 20, 2019 at 12:01 am - Reply

    And how do this with Strings?

  8. Umbra N November 20, 2019 at 12:01 am - Reply

    public class Application{
    public static void main(String[] args){
    System.out.println("I LOVE YOUR CHANNEL!");
    }
    }

  9. K Choudhury November 20, 2019 at 12:01 am - Reply

    I love you

  10. TH3GOAT420 November 20, 2019 at 12:01 am - Reply

    Why does the /** comment exist? Or does it not only make the code blue instead of green(/* comment)?

  11. ThatOne Otaku November 20, 2019 at 12:01 am - Reply

    Tehhhh, why Do-While? I mean, why not While? Whats the difference? Both do the same things mate!

  12. sorrefly November 20, 2019 at 12:01 am - Reply

    Is it possible to print a string if the number doesn't corrispond to 5 in the "do-while" method? Like "Wrong number, try again".

  13. Chris Sam November 20, 2019 at 12:01 am - Reply

    nice vid

  14. Raluca Marinescu November 20, 2019 at 12:01 am - Reply

    extraordinary

  15. Alex November 20, 2019 at 12:01 am - Reply

    Your channel is phenomenal – so glad to have found you. High five!

  16. Sifer November 20, 2019 at 12:01 am - Reply

    Loving your videos so far however, I have a quick question for you. Couldn't you have just done the following:

    Scanner scanner = new Scanner(System.in);
    int input = 0;

    while (input != 5) {
    System.out.println("Please enter the number 5");
    input = scanner.nextInt();
    }
    System.out.printf("You entered 5");

    and not repeat your self with the first loop? To me both loops seem just as efficient as each other or am I missing something? Thanks 🙂

  17. Tanishq Chaudhary November 20, 2019 at 12:01 am - Reply

    what if I want user to say to continue or not?
    for example:
    if user says "yes",then it will repeat
    and if user says "no",it will terminate

  18. Walter Straub November 20, 2019 at 12:01 am - Reply

    Thank-you for doing this, it's very helpful.

  19. Josh Stivers November 20, 2019 at 12:01 am - Reply

    Dude seriously you rock! This series is top notch and you really have a knack for teaching, big thanks for these.

  20. perry blunt November 20, 2019 at 12:01 am - Reply

    Thanks you very much, most tutorials uses numbers and counter to explain loops.I really appreciate the real world example you did here. keep it coming.

  21. ABC DEF November 20, 2019 at 12:01 am - Reply

    The issue that arose at 6:00 is an example of what kind of problem? Syntactic? I wish people would do more tutorials on those sort of things!!! 

  22. boxertest November 20, 2019 at 12:01 am - Reply

    Thank you for this video series 🙂 I preparing for my Oracle java associate exam and I wanted to learn java from the ground up and your videos have been very helpful. Just one suggestion, can you put up sample projects to build or practice on. Thanks again. 🙂

  23. luis sanchez November 20, 2019 at 12:01 am - Reply

    What's the differents between if statement and while loop and do while

  24. Cave of Programming November 20, 2019 at 12:01 am - Reply

    Don't worry, it's not necessary. Just type it out and change it a bit and run it, to make sure you are able to use it yourself. Then next time you need it, you can simply Google while loops Java to find an example that you can adapt. This is basically how I learned Java myself.

  25. J.D.M's November 20, 2019 at 12:01 am - Reply

    I understand how it works, but there's no way I can remember all that code!

  26. Razt November 20, 2019 at 12:01 am - Reply

    Like if you Like Likes!

  27. Alimon Pito November 20, 2019 at 12:01 am - Reply

    thanks for awesome tutorials,:)

  28. jackie4244 November 20, 2019 at 12:01 am - Reply

    Thank you SO much for making this video! It helped me with a similar program I was working on. Out of all the hundred of tutorials do-while loop videos, yours was the only one that actually helped me. Thank you!

  29. Chitra Indalkar November 20, 2019 at 12:01 am - Reply

    good tutorial, simple example which clears concepts

  30. Cave of Programming November 20, 2019 at 12:01 am - Reply

    @DoomCatcher Yes it's the right type, don't worry. You'll need to learn an Android-specific API later on in addition. Phones themselves run a different edition of Java, but the language that you type itself is still all the same.

  31. adam November 20, 2019 at 12:01 am - Reply

    @caveofprogramming thanks for the reply, I slightly understand it, I just need to make sense of why aload } of at the bottom. But yeah if you ever do a tutorial for it what would you call it, ill be looking out for it.

    Also someone was saying to me theres different versions of the java programming language such as java mobile. Im wanting to learn java for android app development. Is this the right type of java for me to learn?

  32. Cave of Programming November 20, 2019 at 12:01 am - Reply

    @DoomCatcher Hi there, yeah they are confusing at first. I'll definitely think about making a video on them specifically; I need to make a couple of vids on parameters and setters first though. Basically whenever you want to specify a chunk of code, you surround it with { and }. So when you want to say what code belongs in a loop or a class or an if or whatever, you need to put a { in front of it and a } after it. These "blocks" can be nested inside each other too.

  33. adam November 20, 2019 at 12:01 am - Reply

    Nice videos but I still Really can't understand the full purpose of the { and } I know they are to do with opening and closing stuff you create in the programme but it really confuses me to when and why you need to make new ones and why theres aload at the bottom at the end of each programme.

    I could be done with a full tutorial video just to fully explain them if you make one please let me know thanks.

  34. adam November 20, 2019 at 12:01 am - Reply

    @Kroweer ive been following newboston aswell, i find this guy to explain stuff in better detail though and the shortcuts are real helpful

Leave A Comment

*