mardi 3 décembre 2019

First element of String splitting not working used in if-clause

I could use some help to figure out a problem with the if-clause, even if I type add as the first word in userInput, the if-clause returns false for some reason.

Scanner scanner = new Scanner(System.in);

String userInput = scanner.nextLine();
String[] splitUserInput = userInput.split(" ");

if(splitUserInput[0] == "add")
return true; 

Aucun commentaire:

Enregistrer un commentaire