• Post Reply Bookmark Topic Watch Topic
  • New Topic

Weird Eclipse bug?  RSS feed

 
Scott Kimberly
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i have this section of code:



Its telling me that the last else-if is a syntax error. I tried it as an else and and else-if and it keeps insisting its wrong. Thats the only error in my code...so um....wtf?

My code is choosing a random number between 0 and 4. 0,1,2,3.

If its 0 or 1, dosomething. if its 2, dosomethingelse. if its 3, doanotherthing. How is this a syntax error???
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you fell foul of one of the most annoying mistakes, check out your ';'
 
Scott Kimberly
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:you fell foul of one of the most annoying mistakes, check out your ';'


Ugh. Thankyou. I dont even know how a semi colon got to the end of that line to do that.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everybody does that!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just as an addendum, note that it did not simply "tell [you] the last else-if is a syntax error." It specifically told you that it was an "'else' without 'if'" error. Since we know the compiler is much more reliable than we are, we can use that to backtrack from our else to find what mistake we made that disconnected that else from its if.

The moral of the story being, read the error messages closely, trust them, and be prepared to question your assumptions.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!