Why this java code is showing error?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why this java code is showing error??

Thie code prints the seat type of a train coach based on seat no. I have run the same code on BLUEJ , & CMD ON COMPUTER ,and it works fine, but it shows error on Solo learn. I was totally irritated for 2 hrs and couldn't find any error but and finally I have to run it on COMPUTER. https://code.sololearn.com/cNZWkG1Iitsd/?ref=app

22nd Feb 2018, 7:12 AM
Mr.Curious
Mr.Curious - avatar
5 Answers
+ 17
You probably did copy / paste this code from your IDE to the Sololearn playground. I do not know why, but in that case, SL often recognizes empty fields as some (hidden) characters and report error. This is best seen in the web version of SL (like some dots). You need to manually delete all empty fields in SL (with backspace) and format the lines of code again. Here's your code, works perfect : https://code.sololearn.com/cGxM4K51eKKi/?ref=app
24th Feb 2018, 6:21 AM
LukArToDo
LukArToDo - avatar
+ 3
nice code. but i don't know the correct reason why it is working.
22nd Feb 2018, 3:14 PM
shobhit
shobhit - avatar
+ 2
because you are using loops to take input. This is not available on sololearn. But you can definitely run it on your pc.
22nd Feb 2018, 7:18 AM
shobhit
shobhit - avatar
+ 2
Thanks alot , I also thought some thing like this, as when I retyped this code once again in Solo learn , it worked fine. This problem also arises when I copy my codes typed in solo learn to hackerrank . I also failed to complete a challenge in hackerank , because of this, as sololearn gives a better typing environment , I tried to type the code in solo learn and paste it in hackerrank.😑😑😞 Now I think , I have to use pc for hackerrank.
24th Feb 2018, 6:32 AM
Mr.Curious
Mr.Curious - avatar
0
no frnd , you can ,check out this code :- https://code.sololearn.com/cNlBsywU8yW5/?ref=app
22nd Feb 2018, 7:47 AM
Mr.Curious
Mr.Curious - avatar