m trying to write a super simple piece of code which asks "are we nearly there yet" if the user inputs yeah they get the answer "finally" if the user says anything other than yeah the computer keeps asking are we nearly there yet?
for some reason when I run the code below even if I type "yeah" after the first prompt the computer just keeps printing are we nearly there yet? and can't get through the loop.
import java.util.Scanner;
class FirstAttempt {
public static void main(String args[]) {
Scanner s= new Scanner(System.in);
String a =" ";
System.out.println("are we nearly there yet?");
a = s.next();
while ( a != "yeah" & a != "Yeah")
{System.out.println("are we nearly there yet?");
s = new Scanner(System.in);
a = s.nextLine(); }
System.out.println("finally");
} }