+ 1
Why does rhis code result in error?
Error says illegal type start for the else statement https://code.sololearn.com/ctvEZtw613zH/?ref=app
7 Réponses
+ 4
System.out.println("Username:");
System.out.println(inPut.nextLine());
System.out.println("Password:");
System.out.println(inPut.nextLine());
String username = inPut.nextLine();
String password = inPut.nextLine();
This is a problem because each input.nextLine() expects an input. In sum: 4 inputs.
First store the input, then print it:
String name = input.nextLine();
String password = input.nextLine();
System.out.println("Name: " + name);
System.out.println("Password: " + password);
+ 4
A semicolon ends a statement. If(condition); <- the rest of the code does not belong to the if statement.
The curly bracketts creates a block:
If(){
//if block -> everything in it belongs to if
}else{
//else block -> every thing in it belongs to else
}
+ 3
Your welcome :)
+ 2
For starters, you used a semicolon instead of curly brackets, and the condition will definitely be true, because you used an assignment operator instead of comparison. But then that would always be false, because you can't really compare strings like that. Use
username.equals("ACAB)
+ 2
On line 15, it tests the condition, but then does nothing with it. It will print "Access Granted" no matter what, then reaches the curly bracket & the else statement and is like u wot m8
+ 2
Thank you!!!
+ 1
Thank you!! I changed the condition but i don't understand which semicolon i used instead of the curly brackets