+ 1
Why won't this code work?
import java.util.Scanner; public class Password { public static void main(String[] args) { string I; int I = 12; Scanner input = new Scanner (System.in); System.out.println("input:"); string I = input.next(); if(input.equals(I)) System.out.println("Hello!"); }else{ System.out.println("Nope"); } } }
4 odpowiedzi
+ 2
My solution:
import java.util.Scanner;
/**
*
* @author Bilder
*/
public class Password {
public static void main(String[] args){
String In;
int I = 12;
Scanner input = new Scanner
(System.in);
System.out.println("input:");
In = input.next();
if(In.equals("I")){
System.out.println("Hello!");
}else{
System.out.println("Nope");
}
}
}
So you see where are your mistakes ;)
+ 1
"public class Password {"
this cannot be before you main args and the next { has no reason to be there. also your if statement should open with a curly bracket .
0
Delete class password
0
You need to capitalize String, and there is no need to put String in front of l again when loading it, and l must be initialized with two quotation marks (not single quotes or else it will be a character type). You also can't put the same variable name l even if you change type.