By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,542 Members | 1,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,542 IT Pros & Developers. It's quick & easy.

can't get out from while loop using string input

P: 2
Dear all,
I'm really appreciated if anyone can help me.
I would like to ask regarding the following code...

[B]System.out.println("Enter Pre_condition or q to quit):");
while(condition.equalsIgnoreCase("q")==false)
{
condition = Input.nextLine();
if(condition.equalsIgnoreCase ("q"))
break;
else
PreCondition[count] = condition;
} [/b]


My problem is I can't get out from the while loop. I really weird.
I've used many others functions for string such as "compareTo,equals",
however it still didn't work... the while loop still can't stop when the user
entered "q" as an input.
I'm really hope that anybody can help me.
Thank you very much for anyone help.

Regards,
Normadiah
Dec 27 '06 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
Dear all,
I'm really appreciated if anyone can help me.
I would like to ask regarding the following code...

[B]System.out.println("Enter Pre_condition or q to quit):");
while(condition.equalsIgnoreCase("q")==false)
{
condition = Input.nextLine();
if(condition.equalsIgnoreCase ("q"))
break;
else
PreCondition[count] = condition;
} [/b]


My problem is I can't get out from the while loop. I really weird.
I've used many others functions for string such as "compareTo,equals",
however it still didn't work... the while loop still can't stop when the user
entered "q" as an input.
I'm really hope that anybody can help me.
Thank you very much for anyone help.

Regards,
Normadiah
Try



Expand|Select|Wrap|Line Numbers
  1. System.out.println("Enter Pre_condition or q to quit):");
  2. String condition = Input.nextLine();
  3. while(!condition .equalsIgnoreCase("q")) {
  4.     PreCondition[count] = condition;
  5.     System.out.println("Enter Pre_condition or q to quit):");
  6.     condition = Input.nextLine();
  7.     count++;
  8. }
Dec 28 '06 #2

P: 2
Dear r035198x,

Thank you very much for your help. It's work :)
Dec 28 '06 #3

10K+
P: 13,264
Dear r035198x,

Thank you very much for your help. It's work :)
Welcome. Hope you'll come back for more help or to help others where you can as well.
Dec 28 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.