File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes while(true) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "while(true)" Watch "while(true)" New topic
Author

while(true)

Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
I want to know the line no(1) execution. What the (1) check. What is the other way we can specify line no (1)



Thanks,
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12921
    
    3

A while(true) loop is an infinite loop - the loop never terminates (at least, not until you stop the program).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
How can I write the line(1) using the If condition?
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
Set a boolean method and test on that.


Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12921
    
    3

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

Joined: Oct 30, 2007
Posts: 165
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

Joined: Jul 08, 2003
Posts: 24054
    
  13

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."


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: while(true)
 
Similar Threads
synchronization
Using static variable to start and stop a thread
why one thread runs
Wait , notify() ...explain this output
Explain me this output (notify)