Making a loop hesitate.

S

snewcrash

I'm new to java so sorry if this is a stupid question. I have a program
where I have 360 lines output. I need the screen to pause each time it
fills up. So far I made a for statement for lines 1-20, 20-45, etc. How
do I get the screen to pause at the end of each for statement? I've
been looking at Thread.sleep, but I'm unsure how to use it in my
program. This is what I have so far:

http://pastebin.com/447592
 
C

Chris Smith

snewcrash said:
I'm new to java so sorry if this is a stupid question. I have a program
where I have 360 lines output. I need the screen to pause each time it
fills up. So far I made a for statement for lines 1-20, 20-45, etc. How
do I get the screen to pause at the end of each for statement? I've
been looking at Thread.sleep, but I'm unsure how to use it in my
program.

Easy:

try
{
Thread.sleep(500);
} catch (InterruptedException e) { }

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
M

mikkisingh

wouldn't a simple comparison of the counter work for u ? something like
....

for(counter =0 ; counter <....) {
//do ur stuff
if (counter == 20 || counter ==44 ....) {
Thread.sleep(....)
}
}
 
M

Monique Y. Mudama

I'm new to java so sorry if this is a stupid question. I have a
program where I have 360 lines output. I need the screen to pause
each time it fills up. So far I made a for statement for lines 1-20,
20-45, etc. How do I get the screen to pause at the end of each for
statement? I've been looking at Thread.sleep, but I'm unsure how to
use it in my program. This is what I have so far:

http://pastebin.com/447592

I don't know your ultimate goal, but wouldn't it be better to wait on
user input every 20 lines or so?

asdfa
asdfa
fasafda
Press <Enter> to continue ...

That way, the user gets to decide how much time they need to digest
the data ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top