I was beginning to think I was getting the hang of the basics in Java, but then I found myself back in the dark. The code here is quite meaningless, but my question is; if I type in "yo" to the question "What is your name", in my mind, the program should print "yo man!", but instead it prints "lala".
Why? I don't understand.. :-/
import java.util.Scanner;
public class test {
public static void main(String[] args) {
System.out.println("What is your name?");
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
System.out.println("Hello, "+ str);
if (str == "yo"){
System.out.println("yo man!");
}
else System.out.println("lala");
sc.close();
}
}