Skip to content
Advertisement

Tag: while-loop

Password Checker in java with do while

I need to write a password checker which ensures that password correct. Firstly I prompt the user enter the password Secondly, I prompt the user to reenter the password thirdly, I need to check that the passwords are identical But this steps need to repeat 1 through 3 until password is correctly entered twice. Here is my code. But i

Basic Java Hangman

I am just starting to learn Java as my first programming language. In class we were assigned to make a basic Hangman game with the use of a while and for loops. What I have so far When the user inputs the first guess it does recognize that that characters that he/she guessed was corrected but just continues on and

How to exit a while loop after a certain time?

I have a while loop and I want it to exit after some time has elapsed. For example: Answer Thus the statement Checks if it has been 10 seconds or 10,000 milliseconds since the loop started. EDIT As @Julien pointed out, this may fail if your code block inside the while loop takes a lot of time.Thus using ExecutorService would

Advertisement