Well I've always had some problems with this, but I can't seem to find any answers.
I'm asking for you to look at the second section of code, when I run this code and reply to "so your name is (name)?" with "yes", it runs the else instead of the if.
I'm asking for you to look at the second section of code, when I run this code and reply to "so your name is (name)?" with "yes", it runs the else instead of the if.
import java.util.Scanner;
class Learn1 {
public static void main(String[] args) {
double chicken = 4.14159625;
int beef = 1;
double pie;
pie = chicken - beef;
System.out.print("Hello ");
System.out.print(pie);
System.out.println(" Worlds!");
System.out.println("name please!");
Scanner name = new Scanner(System.in);
System.out.println("so your name is " + name.nextLine() + "?");
Scanner yesno1 = new Scanner(System.in);
if (yesno1.nextLine() == "yes"){
System.out.println("OK!");
}else{
System.out.println("ah...");
}
}
}