This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes byte Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "byte" Watch "byte" New topic
Author

byte

Vishal Arora
Greenhorn

Joined: Jul 29, 2005
Posts: 9
The output of this code given below is "Welcome to Java".Can somebody tell me why it is not an infinite loop printing welcome to java.
public class XTC {

public static void main ( String [ ] args ) { // ---> line 1
XTC x = new XTC();
x.infiniteLoop();
}
void infiniteLoop ( ) {
byte b = 1 ;
while ( ++b > 0 ) ;
System . out . println ( " Welcome to Java " ) ;
}

}
satya mamillapalli
Ranch Hand

Joined: Jun 22, 2005
Posts: 63
Watch the end of WHile loop? It ends with semicolon.(it is an empty loop)

Actaully empty loop will execute 126 times and comes out because after 127 it will start with -128..

Thanks

Satya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: byte
 
Similar Threads
Doubt with ++ operator
interface to class assignment
why is this not an infinite loop?
Which method to call ?
static method