My java if statement is not working as expected. When the end user answers the question in either yes or no, I want that answer to drive the output from the if/else statement. However, no matter what the answer is, the code jumps to the else piece. What am I doing wrong?
public void door() {
Scanner keyboard = new Scanner(System.in);
System.out.print("Is the mailbox door open (yes or no)?");
String door = keyboard.next();
this.door = door.toUpperCase();
this.door = "YES";
this.door = "NO";
String open = "You should close the mailbox door!";
String close = "The mailbox door is closed.";
if (this.door == "YES") {
System.out.println(open);
}
else
System.out.println(close);
}