Why is the code not taking input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
23rd Jan 2024, 1:26 PM
zeeshan
zeeshan - avatar
3 Answers
+ 3
Ausgrindtube I uncomment both lines and entered <64 3.14>, it returns true and print the variable as 64. I think it checks the Scanner object has a valid float or not, not the variable a.
23rd Jan 2024, 3:54 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 3
zeeshan Learn Java course then you will understand why you are not getting input? 1) Uncomment 2) It only accepts integer value 3) If I enter value in float it shows java.util.InputmismatchException Because of incorrect or mismatch data type If you know the basics of java you will understand these things.
23rd Jan 2024, 3:59 PM
RšŸ’ šŸ‡®šŸ‡³
RšŸ’ šŸ‡®šŸ‡³ - avatar
+ 1
Will it accept a float if the variable is declared as an integer?
23rd Jan 2024, 3:14 PM
Ausgrindtube
Ausgrindtube - avatar