I am working on a eclipse project for a class i'm taking part in and for some reason this one else if stating keeps giving me the error message "Exception in thread "main" java.lang.Error: Unresolved compilation problem: Syntax error on token "else", delete this token". I do not know why I keep getting this error and was wondering what to do. Ive attached a picture of the code for context.
#Else if issue
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
there are several issues
so first line 71
it closes the else if with a ;
remove that
then you shouldnt really use Scanner#next()
and never compare strings with ==
but instead use .equals method
although a switch statement might make more sense here
Usually.. yes. Extremely rare to purposefully do that.
just dont
thats bad advice for a beginner, because they dont understand what it really does
The semicolons were a mistake and removing them fixed my code and my teacher is making us use the Scanner class for all of our projects this year.
You right. Sorry I butted in!
using scanner is fine
but you should really prefer to use nextLine() when reading input
even if you read a single character, integer or whatever
do the conversion after reading
(usually)
ok thank you I will start to implement that instead from now one and I will also fix the ==s in my code.