+ 13
My code do not give out what it should be. It says NoSuchElementException. What does that mean ?
11 Respostas
+ 14
Codes in the Code Playground do not run in realtime. Your code asks for 2 inputs, so you have to put both values in the input box, like this:
Jasmin
yes
+ 7
Hey Jasmin In this case it means that you are not giving it two pieces of information required for the two inputs, when I tried it with my name and the string "yes" it worked. If you skip the input you get the mentioned error.
However, I should also let you know that you won't get the expected output when you enter the string "yes" as when you are comparing strings you should use the .equals () method as == compares the addresses and not the content of the strings thus it will mostly default to false.
Hope it helped!
+ 6
Jasmin ↩
Yes ▶
+ 4
Try this Robert Brown Farley (brofarops) , your inputs are: Robert yes
https://code.sololearn.com/csdC7KduuHLH/?ref=app
Then try Jasmin's with the same input.
+ 4
ok - i don't know why it didn't work initially when i changed it but yup it does work in your example and hers too - Wow! must have been a system glitch -
+ 3
Hi,
replace the == sign with below to get the exact results.
if (like.equals("yes"))
+ 3
jasmin. i noticed an error in ur code at line 14, that might be the reason your code doesn't work. I think to read a string value input using scanner class, the syntax should be String Like=Scanner_name.nextLine();
https://code.sololearn.com/cL5MApgANnuD/?ref=app
+ 2
Because you have used twice scanner.next();
Without checking if there’s an input.
+ 1
Try this...
https://code.sololearn.com/c52vkdHahXjq/?ref=app
0
like others may have indicated, need to account for having only 1 line.
If you put in more that 1 line you don't get that exception.
https://www.tutorialspoint.com/java/util/scanner_next.htm
- 1
you a incredibly amazing jazmin.... keep it up