+ 2
How to check if user input equal to a string?
How do i check it?
6 ответов
+ 4
String s = "test";
Scanner input = new Scanner(System.in);
if(s.equals(input.nextLine()){
Your code here
}
+ 2
Option 1:Main method always takes Strings in fact string array.
#2:For any other interface like we apps. You can cast to String variable in try catch
#3: or instance of method can beused
+ 1
you use if, else, and else if statements.
+ 1
by using equals method rather than == operator equal to operator checks there address not the value bt equal method compares content of string
+ 1
Thanks for the help got it working!
0
use scanner method to get input from user. Let it be String n. And then use if (n.equals (required string)==0){} else {}