You can't stop the user from entering anything he wants to enter.
You can refuse to accept input that is not valid.
That implies having a loop that doesn't exit until the program gets the desired...
Type: Posts; User: Norm
You can't stop the user from entering anything he wants to enter.
You can refuse to accept input that is not valid.
That implies having a loop that doesn't exit until the program gets the desired...
Defining it outside of any methods will make it a class variable.
How many times did you execute it? I executed it about 10 times. Sometimes the numbers were the same and sometimes they were different.
Try defining the Random class object outside of the method...
It doesn't on my system. What OS and version of java are you using?
Can you write a small simple program that compiles, executes and shows the problem?
Execute the code, copy the console contents that show the problem and paste it here.
When I execute the code I...
What number do they return? It is possible for a random number generate the same number more than once.