Log in

View Full Version : How do I get a Java program to repeat, start from beginning?


goldberg1337
Oct 4, 2009, 07:32 PM
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!

Perito
Oct 4, 2009, 07:56 PM
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.