0

java why?

Why doesn't this code work? https://code.sololearn.com/c5q2qS5UIplu/?ref=app

18th Jul 2022, 6:12 PM
Bogyo - Leția Eduard
Bogyo - Leția Eduard - avatar
2 Answers
+ 2
your my_var is an Scanner object. Through this you can use it's methods and for accepting int value as input use nextInt() method of Scanner object so use like cont(my_var.nextInt()); # not cont(my_var);
18th Jul 2022, 6:25 PM
Jayakrishna 🇮🇳
+ 2
Bogyo - Leția Eduard Read the error message "Scanner cannot converted to int" means my_var is an object which cannot be a integer value so you should pass integer value in your method because your method accepts integer. So take integer input using Scanner class object and pass in method.
18th Jul 2022, 7:04 PM
A͢J
A͢J - avatar