0

I want to check for a specific input, and that specific input performs an action. I am using the Scanner class in Java. For example, if the user inputs "name" it should print names, or the user inputs "number", it should print numbers. These should work like commands. Although I tried it and nothing happens. Here is my code:

String input = scan.nextLine();
if(input == "name"){System.out.print("Jafar");}

Although the code produces no errors, it still does not work the way I want it to.

khelwood
  • 52,115
  • 13
  • 74
  • 94

0 Answers0