• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

please help!

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont understand these compiler error messages:'else' without 'if' eg. else if(Label.equals("Lightgray")). if there are different options eg. if(Label.equals("Yellow"))you cant just have 'if' can you! Also: 'illegal start of expression' eg. public boolean action(Event evt, object arg)how is this illegal! Also: 'cannot resolve symbol' eg. method setMessage(java.lang.String)
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Keith,

As these are basic Java questions, I'm going to move this thread to our "Java in General (Beginner)" forum, and then answer them. See you over there!
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are all basic syntax errors, but the best way to pose the question is not to show us only part of a line (because the error could have been triggered by a mistake in the previous line, or *where* you placed this subexpression). I suggest you post a very short but complete program that demonstrates your error.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


'else' without 'if' eg. else if(Label.equals("Lightgray")). if there are different options eg. if(Label.equals("Yellow"))you cant just have 'if' can you!



You can indeed have just "if" -- the syntax of a chain of if/else statements looks like



There's no "else" before the very first "if". Often the "else without if" message comes from leaving out the braces above that group statements together -- for example, this code would give you that message:




Also: 'illegal start of expression' eg. public boolean action(Event evt, object arg)how is this illegal!



This would be illegal if it appeared in the middle of a method. You might be trying to write this at the top level of a class, but you left out a closing brace at the end of the method just before -- that makes it look as if this line is inside a method, and method declarations can't go inside another method.

Also: 'cannot resolve symbol' eg. method setMessage(java.lang.String)



"Cannot resolve symbol" means that the compiler can't find something by a given name. If you are calling the method above and there's no such method, the compiler will say "can't resolve symbol." If you think the method really does exist, you may be trying to call the method on an instance of the wrong class.
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic