+ 1
Java input to variable
I am new to java and I want to receive input and then access the user input with a variable. For example I would liken to use a scanner and then use the users’ input as a variable in an if statement. But It comes back saying I can’t convert a scanner into a string because I was using the scanner variable. Help
5 Antworten
+ 1
thank you but my if statement still is not working corrrectly
my code:
Scanner dog = Scanner(System.in);
System.out.println(“Doggos or cattos?”);
String fat = dog.next()
if (fat == “Doggos”) {
System.out.println(“Good”)
}
else {
System.out.println(“No”)
}
+ 1
ok thank you what does the ignore case do
0
it is only printing the else statement no matter what