• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

while(true)

 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know the line no(1) execution. What the (1) check. What is the other way we can specify line no (1)

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15278
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A while(true) loop is an infinite loop - the loop never terminates (at least, not until you stop the program).
 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I write the line(1) using the If condition?
 
Nickolas Case
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set a boolean method and test on that.


 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15278
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Phillipe Rodrigues:
How can I write the line(1) using the If condition?

You cannot, because if is not a looping construct like while.

You could do this trick with for, but I don't recommend it, because it's more unreadable than the version with while:

[ June 04, 2008: Message edited by: Jesper Young ]
 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while(true) means ?

is it saying while the run() is getting executed or what while(true) checks.when the while condition executes?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Phillipe Rodrigues:
while(true) means ?


It just literally means that as long as true == true, the loop will continue. Since true is always equal to true, it means "loop forever."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic