GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  J2EE  >  Java

 Print  |  
Question:  Can a for statement loop indefinitely

Answer: Yes, a for statement can loop indefinitely. For example, consider the following:for(;;) ;


April 04, 2007 04:56:08 #1
 angelina   Member Since: Visitor    Total Comments: N/A 

RE: Can a for statement loop indefinitely
 

Yes, the for loop can run indefinately by doing this

for(int i=0;;)
{

}

Note: for loop must have at least initialisation step. so the above example for(;;) would not work and will give the compilation error
     

 

Back To Question