Java input to variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

10th Aug 2018, 2:02 PM
NicoChis
NicoChis - avatar
3 Answers
+ 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”) }
10th Aug 2018, 2:26 PM
NicoChis
NicoChis - avatar
+ 1
ok thank you what does the ignore case do
10th Aug 2018, 2:35 PM
NicoChis
NicoChis - avatar
0
it is only printing the else statement no matter what
10th Aug 2018, 2:27 PM
NicoChis
NicoChis - avatar