I am using Java and have been trying to split my string input into 3 parts. For example, my input will be "AND 1 1", and I am expecting it to go into my if-loop where the condition is parts[0] == "AND". But this is not the case, and I am not sure why.
My code is listed below
Scanner stringInput = new Scanner(System.in);
String input = stringInput.next();
System.out.printf("%s\n", input);
String[] parts = input.split(" ");
if (parts[0] == "AND") {
if (parts[1] == parts[2] && parts[1] == "1")
System.out.printf("1\n");
else
System.out.printf("0\n");
}
else {
if (parts[1] == "1" || parts[2] == "0")
System.out.printf("1\n");
else
System.out.printf("0\n");
}