-4
public static void main(String args[]){
    System.out.print("Type new, wil display TRUE:");
    Scanner sc = new Scanner(System.in);
    String userInput = sc.nextLine();

    if(userInput=="new"){
        System.out.println("TRUE");
    }else {
        System.out.println("FALSE");
    }
}

I have no idea why new not equals to new.

Please give me some hints :)

1 Answers1

0

Use userInput.equals("new") instead.

This explains everything: How do I compare strings in Java?

Community
  • 1
  • 1
sparkhee93
  • 1,381
  • 3
  • 21
  • 30