So I was just messing around Java today (since I found out that I learn stuff much easier by doing this) and when I tried to create a simple, and we are talking REALLY simple, password system it won't work!
The problem is that when I type in the correct password it still says it's wrong
If I change the line: " if (Attempt == correctPassword){" to have a number like "123" instead of correctPassword it works when entering "123". I'm just a simple beginner, but I know that a lot of you guys are good at this, so please help?
The problem is that when I type in the correct password it still says it's wrong
Code:
import java.util.Scanner;
public class EksempelOppgave {
public static void main (String[] args) {
Scanner keyboardInput = new Scanner(System.in);
String Attempt;
String correctPassword = "Password";
System.out.println("Enter correct password:");
Attempt = keyboardInput.next();
if (Attempt == correctPassword){
System.out.println("Correct! You can enter!");
}else{
System.out.println("ERROR! Wrong password entered!");
}
}
}
If I change the line: " if (Attempt == correctPassword){" to have a number like "123" instead of correctPassword it works when entering "123". I'm just a simple beginner, but I know that a lot of you guys are good at this, so please help?