• Post Reply Bookmark Topic Watch Topic
  • New Topic

Keep getting an "else" error  RSS feed

 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I keep having an error that I should delete the "else" token at line 39 and I have no idea why or what to do.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never omit braces. Put braces around the if block and the else block.

Never omit braces.
Never omit braces.

Write that on the chalkboard 100 times.

Then remove the ; after the conditional clause; it's prematurely closing the "if" block.
 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everybody manages that error.

There must be a better way to write that test after the if. Put all those names into a Set and use
if (mySet.contains(name)) … else …
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!