• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Array output continuous in output window and won't terminate - Any help!!

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Another simple question I think! Why is the output from this main class not terminating in the output window. The main method is calling an array of 10,000 integers from four seperate text files of telephone numbers. Each file is 10,000 integers long.

When I run this main class it outputs the correct answer but simply does not terminate, and continually repeats the same answer.

Code is as follows:



Any help appreciated!!
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because the givenNumber is always not equal to 0?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've set givenNumber to 83746, and then said, "while givenNumber is not zero," keep going, and going, and going...

As long as givenNumber has a non-zero value, the loop will keep repeating. So within your loop, you should be setting givenNumber to the next value -- or to zero if you want to stop.
 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want it to only run for one cycle then you do not need the while loop.

Or if you want it to run till its down to 0. Trying using a counter variable or something.


[ November 12, 2005: Message edited by: ste fing ]
 
celine scarlett
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thank you both for your answers. It was such an obvious mistake, I feel a bit daft now. Anyway, it is now working perfectly so thank you so much for all your help.

Have a great weekend!!
reply
    Bookmark Topic Watch Topic
  • New Topic