Someone decided that's what it should return if the user doesn't OK the output :P
That's the only value that's available since technically an empty string "" is an allowed OK return value.
Type: Posts; User: helloworld922
Someone decided that's what it should return if the user doesn't OK the output :P
That's the only value that's available since technically an empty string "" is an allowed OK return value.
Regardless of how he gets the input, he will still have to parse it.
JOptionPane will return a string just as Scanner will return a String. The only difference is that JOptionPane will return null...
The reason you can't parse right away is because you don't know if the user typed in Quit/Exit. It takes a few steps to parse whatever the user typed, so it's better to do the number parsing later.
Two ways: one is to input a string, then wait for the user to type something like quit, and another way is just tell the user to type quit, and catch the exception thrown (or not).
Scanner input...