Jump to content

Press any Key to Continue in Java

xrex64
Go to solution Solved by fizzlesticks,

Pressing any key in java is overly complicated and not worth attempting.

 

The following will wait for enter to be pressed.

System.out.println("Press enter to continue...");try{        System.in.read();}catch(Exception e){	e.printStackTrace();}

What line(s) of code do I need to put in my program to have a press any key to continue feature. I want to display one message, then the user must press a key to get another. 

"When in doubt, don't take your wallet out." - Dad


 


† TTCF Member †

Link to comment
Share on other sites

Link to post
Share on other sites

Pressing any key in java is overly complicated and not worth attempting.

 

The following will wait for enter to be pressed.

System.out.println("Press enter to continue...");try{        System.in.read();}catch(Exception e){	e.printStackTrace();}

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

I don't see why you wan't the "press any key to continue" function but I'm pretty sure that you've got your reasons.

 

 

Pressing any key in java is overly complicated and not worth attempting.

 

The following will wait for enter to be pressed.

System.out.println("Press enter to continue...");try{        System.in.read();}catch(Exception e){	e.printStackTrace();}

As he said, that would be one of the most efficient ways of doing it

Link to comment
Share on other sites

Link to post
Share on other sites

I don't see why you wan't the "press any key to continue" function but I'm pretty sure that you've got your reasons.

 

As he said, that would be one of the most efficient ways of doing it

 

 

 

Pressing any key in java is overly complicated and not worth attempting.

 

The following will wait for enter to be pressed.

System.out.println("Press enter to continue...");try{        System.in.read();}catch(Exception e){	e.printStackTrace();}

Thanks guys. 

"When in doubt, don't take your wallet out." - Dad


 


† TTCF Member †

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×