I've written a simple program to check if the input is the letter O or not. For some reason, even when I type the letter O, the program outputs that the input is not the letter O. I have used the Eclipse debugger to ensure that the input variable actually equals "O".
import java.util.Scanner;
public class scannerTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Give your input. I will tell you if your input is 'O' or not");
String input = scan.next();
if (input == "O"){
System.out.println("Your input was 'O'");
}
else {
System.out.println("Your input was not 'O'");
}
}
}