Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   How do I get a Java program to repeat, start from beginning? (https://www.askmehelpdesk.com/showthread.php?t=402709)

  • Oct 4, 2009, 07:32 PM
    goldberg1337
    How do I get a Java program to repeat, start from beginning?
    Hey guys, this is my first post.

    I was just wondering how to code a Java program to start again from the beginning. I'm trying to do a simple if... while loop and I want to be able to get it so that unless the person enters "quit" it will start again at the beginning. I'm only just starting with Java in computer science, so if you can answer this as simply as possible it would be much appreciated!
  • Oct 4, 2009, 07:56 PM
    Perito

    I don't program in Java, but in other languages, the only way to do that is to write a loop in the MAIN subroutine of the program. Something like

    do {
    ...
    } while (condtion);

    or

    while (condition)
    {
    ...
    }

    I would normally use a Boolean variable and set it to FALSE to exit the loop.

  • All times are GMT -7. The time now is 01:00 AM.