0
What is the problem with my code
Please check the PasswordChecker code on my profile and help me figure out the problem with the code. It works perfectly on my computer but it gives NoSuchElementException here on sololearn.
7 Réponses
+ 7
im no java pajeet but I imagine the reason it works on your computer and not here, is because sololearn doesn't allow whatever you're trying to do.
+ 1
It works fine in the Code Playground, unless you enter the incorrect password and don't supply additional entries when you 1st start the program. This is an implementation of how Code Playground takes user input not your code.
If I enter:
"wrong password"
or
"wrong password"
"another wrong password"
You'll get an error because Code playground is expecting another input and you haven't supplied it.
If you enter all three wrong passwords from the get go it works fine. Likewise if you enter the correct password as an entry of your 1, 2, or 3 entries it works fine.
When you run it in Code Playground try supplying all 3 entries (put each on a new line at the input prompt) at the same time.
+ 1
@Varun
You have too keep in mind that this is just a playground and nothing like a real world situation. This is why I don't use it. It's fine for posting code and messing around and learning, but the limitations are awful. For online compilers I use the ones at tutorialspoint.com it's a little buggy sometimes too, but at least you get more compiler options and a command line interface with it along with being able to actually do full projects, upload, download, save and rename real files. Anyway, glad you got it figured out. ;-)
0
I think u have to put the first block in a try and catch block.
0
@ChaoticDawg I know code playground is expecting another input but you can't provide all three inputs at once. So it is not possible. Suggest me an alternative so that it asks for input again. Is it possible in code playground.
0
Yes you can, you enter the first then press return, then the second and return then the third and click submit. At least in the app. If you want me to check on my computer, you'll have to post a link here so I can actually find your code.
Either way most likely a code playground issue. You could try it here:
https://www.tutorialspoint.com/compile_java8_online.php
and see what happens.
You may also try changing your Scanner to nextLine() instead.
0
@ChaoticDawg yes I can provide 3 inputs at once but the user is not going to enter 3 inputs at once. I guess it is not possible to take input again in code playground. It works on computer.