+ 1
I'm getting error ,i don't know why this code run successfully in my ide
This doesn't works with nextInt method import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sd = new Scanner(System.in); int password; do{ System.out.println("Write password"); password = sd.nextInt(); } while(password!=8839); } }
5 ответов
+ 6
There is no problem with the code. Error is because of there is no input present to read.. Note that loop continue is the condition is true that is input is not 8839 so again ask the input.
Sololearn is not interactive so you need to give all required input at once on the pop-up window , it's before start execution. So try :
1234 < press enter >
8839 < press submit >
Runs successfully, that first input 1234 is not password then reads next input, 8839 then condition becomes false. Password is correct so loop terminates. Execution completes without errors...
hope it helps..
+ 1
What are your inputs?
0
NoSuchElement exception
There is no problem with code because same code run successfully in my ide
0
All problem with scanner because scanner has not nextInt method
0
Can you write a code?