while loop / string input not working java
- by Mikeecb
I have looked online and all of the tutorials / questions have pointed me to this. I can't see why this isn't working. Any help would be much appreciated. Thanks
import java.util.*;
public class test {
static Scanner userInput = new Scanner(System.in);
public static void main(String[] args) {
String textEntered = userInput.next();
if (textEntered == "hello") {
System.out.println("Hello to you too!");
}
}
}
I enter "hello" but nothing is printed. Also I have tried next() and nextLine();