What is wrong with this code?Why is it not accepting input from keyboard? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

What is wrong with this code?Why is it not accepting input from keyboard?

https://code.sololearn.com/cYtvVb8IKrJK/?ref=app

9th Dec 2018, 5:08 AM
Mystery
Mystery - avatar
11 Respostas
+ 18
Seems like Sololearn does not support an input using DataInputStream. Try to run this code on your local machine.
9th Dec 2018, 5:36 AM
Igor Makarsky
Igor Makarsky - avatar
+ 14
You need to use the Scanner class for this purpose.
9th Dec 2018, 5:15 AM
Igor Makarsky
Igor Makarsky - avatar
+ 7
Mystery https://www.tutorialspoint.com/compile_java_online.php It's working on tutorialpoint java compiler Just write your input in Stdin and execute MY OUTPUT javac Program.java Note: Program.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. $java -Xmx128M -Xms16M Program enter no. m=76556 I think Igor Makarsky was right that its doesn't have support on Sololearn
9th Dec 2018, 5:46 AM
Rstar
Rstar - avatar
+ 6
Mystery I remove your try catch blocks I got some unreported IO Exception at DataInputStream method
9th Dec 2018, 5:41 AM
Rstar
Rstar - avatar
+ 3
Rstar thanks for the links but it would be better if you told me what is wrong with my code
9th Dec 2018, 5:28 AM
Mystery
Mystery - avatar
+ 3
9th Dec 2018, 5:38 AM
Mystery
Mystery - avatar
+ 3
Rstar yeah i got that too therefore i used try and catch
9th Dec 2018, 5:42 AM
Mystery
Mystery - avatar
+ 2
Igor Makarsky but what if i want to use DataInputStream?
9th Dec 2018, 5:16 AM
Mystery
Mystery - avatar
+ 2
Igor Makarsky i know using Scanner is easier way but I have DataInputStream in my syllabus so i need to do it using this only
9th Dec 2018, 5:27 AM
Mystery
Mystery - avatar
+ 1
JamiešŸ’ no. I think I need to try that. Thanks. But still the question remains that is what is wrong with it that it won't work in codeplayground?
9th Dec 2018, 5:35 AM
Mystery
Mystery - avatar