0
Where's the error?
2 Réponses
+ 3
The variable userInput is a Scanner and only accept Scanner methods to be used.
In your code you are using String methods in a Scanner variable.
// Problematic piece of code
userInput.toLowerCase().contains(example)
If you pass the value of Scanner to a String and use the methods correctely you are good to go.
+ 1
You need to store the input in a variable to use it. Of type String in your case. The problematic lines fixed (9-12):
Scanner userInput = new Scanner(System.in);
String input = userInput.nextLine();
System.out.println("Ketikkan kata/kalimat: " + input);
if(input.toLowerCase().contains(kataTertentu.toLowerCase()))