• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loop Doubt  RSS feed

 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the output as
""HiHelloHiHelloBye"
But I am getting only "HiHelloHiHello"
I dont know why the content inside the if loop is not read.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the time you get to if (x ==1), x is no longer 1. You can verify this by adding System.out.println(x) to the line before the "if."

ps - It's called an "if statement" and not an "if loop"
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:By the time you get to if (x ==1), x is no longer 1. You can verify this by adding System.out.println(x) to the line before the "if."

I'd also put on inside the while loop, so you can see it changing in there.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah , now I unserstood

Thank you friends...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!