• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

endless loop question

 
Ranch Hand
Posts: 91
Notepad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see the following program



this program gives me endless loop when i comment line 1.
I know the logic of for loop makes it to be endless loop but the above code compiles and runs successfully even if it has endless loop in code
is it related to static instance variable?
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sumit kothalikar wrote:see the following program
code compiles and runs successfully even if it has endless loop in code



Why do you expect a error here?
 
Ranch Hand
Posts: 400
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sumit kothalikar wrote:see the following program



this program gives me endless loop when i comment line 1.
I know the logic of for loop makes it to be endless loop but the above code compiles and runs successfully even if it has endless loop in code
is it related to static instance variable?



This code will always execute an endless loop whether you comment line 1 or not, try to wrap the for loop code into {}.


HTH

Minhaj
 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Line 1 has no impact in making or stoping endless loop
 
sumit kothalikar
Ranch Hand
Posts: 91
Notepad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
abimaran

i did'nt mean to say error but the code goes into endless loop when i comment line1

 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sumit kothalikar wrote:abimaran
i did'nt mean to say error but the code goes into endless loop when i comment line1



What happen when un-comment line? It also should give endless loop!
 
sumit kothalikar
Ranch Hand
Posts: 91
Notepad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is not giving endless loop though it should be on my machine.
i did this code for my understanding that static variable has nothing to do with endless loop
and i noticed that even writing a semicolon instead of any statement does not result into endless loop
this code runs and compiles without giving endless loop



thanks
it is solved my doubt is cleared
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sumit kothalikar wrote:this code runs and compiles without giving endless loop



Could you please explain how .there is no endless loop

i am seeing a endless loop over here
 
reply
    Bookmark Topic Watch Topic
  • New Topic