Here's my code. I'm super noobie so don't flame me too hard haha. I've tried a few different ways, and looked at numerous posts and sites about how to close loops. I think the problem is that (i==("quit")) is not recognizing when the user types in quit. It just loops infinitely through making me input a new word and telling me it's the wrong word.
heres the code.
package monty;
import java.io.*;
import java.io.Console;
import java.util.Arrays;
import java.io.IOException;
import java.util.Scanner;
public class firsttry2 {
public static void main(String[] args) {
System.out.print("Enter the word 'quit' to end this program. Otherwise, it will run indefinitely.");
int x=0;
Scanner in=new Scanner(System.in);
while (x<1) {
String i;
i=in.next();
if (i==("quit")) {x++; in.close(); break;}
else {System.out.print("You did not enter the word 'quit'. Please try again .");
}
}
}
}
thanks for any help you guys can give me! I also tried it with while (true) and couldn't get that to work either. same result, doesn't recognize when i type 'quit'.