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 Array output continuous in output window and won't terminate - Any help!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array output continuous in output window and won Watch "Array output continuous in output window and won New topic
Author

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

celine scarlett
Ranch Hand

Joined: Nov 06, 2005
Posts: 93
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!!
Stephen Foy
Ranch Hand

Joined: Oct 17, 2005
Posts: 143
because the givenNumber is always not equal to 0?


Stephen Foy - Microsoft Application Development Consultant
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Stephen Foy
Ranch Hand

Joined: Oct 17, 2005
Posts: 143
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

Joined: Nov 06, 2005
Posts: 93
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!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array output continuous in output window and won't terminate - Any help!!