Using scanner with if statements

Viewed 20

In my code, I'm trying to use Scanner with System.in to have a user input which is then passed through a basic if statement.

Scanner code:

Scanner userInput = new Scanner(System.in);

String theirSelection = userInput.nextLine();

If statement:

if(theirSelection == "Rock") {

The system isn't returning the if statement as true when I type Rock and hit enter, and I do have

import java.util.Scanner;

At the top of my doc

0 Answers
Related