Why does the SoloLearn IDE show a different line number to the line of the exception? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why does the SoloLearn IDE show a different line number to the line of the exception?

I've noticed on many occasions that the SoloLearn IDE gives a line number different to the line of the exception. https://www.sololearn.com/post/482329/?ref=app

1st Aug 2020, 6:47 PM
Michael
Michael - avatar
5 Answers
+ 3
hey i just noticed same is the case with cpp ide and many other languages too here. quick tips: accept it as a feature and whenever you see this error just do lineNo-1.😅
1st Aug 2020, 7:02 PM
RKK
RKK - avatar
+ 3
Compiler search for semicolon till next valid token.. So it's found on line 4 without prevoius variable declaration closed.. So it saying Expected ; at line 4. Check by adding semicolon just before like ; String a;
1st Aug 2020, 7:06 PM
Jayakrishna 🇮🇳
+ 2
I think code is shorted and prepared before it is compiled, so compiler has different version eg without comments, empty lines, with rewritten Scanner command.
1st Aug 2020, 7:19 PM
zemiak
+ 1
Yes that works. I'm sure there's some reason, maybe a package declaration we can't see. But it seems if you import a utility the line numbers match.
1st Aug 2020, 7:07 PM
Michael
Michael - avatar
+ 1
zemiak, I think that might be the case.
1st Aug 2020, 7:27 PM
Michael
Michael - avatar