0

Ok, so when I run this code, then put in the value "y" as the input value for variable response, I keep getting a printed result of false for the logic statement (response == "y"). What am I doing wrong? This is the result window

import java.util.Scanner;

class Main {

  public static void main(String[] args) {

    Scanner UserInput = new Scanner(System.in);  

    System.out.println("\nResponse:");

    String response = UserInput.nextLine();

    System.out.println(response == "y");

  }

}

0 Answers0