Hiya - I’ve been lurking the forums for a while looking for good re-introductions to Java programming (I’ve done a bit of C# about a year ago).
Anyway - I’ve been following a series of videos on TheNewBoston on Java, and I’ve hit a bit of a dead end.
I am trying to compare the contents of a text String to a String value in an If statement, but I can’t seem to get it to acknowledge that the two are the same - Could you try and explain what I am doing wrong? The video only deals with Int comparing which is pretty simple to understand, compared to my own little attempt.
import java.util.Scanner;
class inputtest {
public static void main(String arg[]) {
Scanner userinput = new Scanner(System.in);
String ishumantest;
System.out.println("Are you a human? If so type in yes");
ishumantest = userinput.nextLine();
// FOR DEBUGGING INPUT
//System.out.println();
if (ishumantest == "yes")
{
System.out.println("You are welcome to enter.");
}
else
{
System.out.println("Non-Humans not allowed.");
}
}
}


