The Artima Developer Community
Sponsored Link

Java Answers Forum
While Loop Coding

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brook

Posts: 12
Nickname: brook
Registered: Sep, 2002

While Loop Coding Posted: Oct 28, 2002 6:32 AM
Reply to this message Reply
Advertisement
I have code where I am using a "while" statement. As long as the User presses the number 1 on the keyboard, the program loops back to the start, which is perfect, that is what I want. If a User press the number 0 on the keyboard, the program should stop and ... this is the part of the "while loop" that I don't understand how to code. Below is the "While Loop" that I have, as well as the ending line.


public static void main(String[] args)
{
String another ="1";
while (another.equals("1"))
.....NOW WHAT?......AS YOU CAN SEE, MY LOOP IS INCOMPLETE. I DON'T KNOW HOW TO CODE THE 0 PORTION.

...at the bottom after the System.out.Prinln() I have the following line of code:

another = Console.readString("To place another order press(1). Press 0 to quit? ");

Of course, the number 1 works but the 0 doesn't.

Help and thanks.

Topic: Java's APIs for XML (JAXP, i think) Previous Topic   Next Topic Topic: Newbie question: How to compile servlet

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use