• 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

<identifier> expected and illegal start errors

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I keep getting identifier expected and illegal start errors on the following code:



Any thoughts? What am I not doing, or doing wrong? Thanks in advance.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are those ...(dots) part of the code?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Is that the exact code that you're trying to compile, or is that just part of a program?

An error like "identifier expected" or "illegal start of expression" means that you've made some syntax error, you've written something that is not syntactically valid Java code. The error message that the compiler gives you points out exactly what it thinks is not correct and in which line the error occurs. Look carefully at the error message and look at the place in the code that it points out.

Without any more detailed information it's hard to give you an exact answer what you're doing wrong.
 
Kyle Tuft
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. I should have been more specific. This is part of some open source code I'm trying to modify; the ....'s are for a long list of new recipes being added, which were there already when the program was functioning. I added lines 18-25, and now it's throwing errors. I've attached a screenshot of the compiler with the errors; the screen is scrolled up as far as it can go (part of the errors are cut off; I don't know if this means that the problem starts further up in the code). It seems like starting at line 31 the compiler begins to find fault with almost every identifier and symbol. Until I added lines 18-25, there weren't any errors; the code compiled just fine. When I added these lines in, I got over 100 fatal errors. Does this help? I'd like to resolve this; I can provide more info if it'd be useful.
Java_Id_error.png
[Thumbnail for Java_Id_error.png]
Errors.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kyle Tuft wrote:Thank you. I should have been more specific.



Yes. Those error messages are always associated with a specific line of code, so you should have told us which lines of code had which error messages.

(Or was that screenshot supposed to tell us that? It would be much more convenient if you just copied and pasted the text as text. I find that if I download those images it starts up a whole separate application to display it, and then half the time it still isn't readable, so I never do that.)

I do notice that line 24 of your post is missing a comma, though.
 
Kyle Tuft
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. That was it! I know the compiler should tell me where the problem is, but (as the screenshot showed) I couldn't trace the source of the problem because my compiler runs out a command line, which wouldn't let me scroll up and see all the errors .

I should probably use another compiler that would show me all the errors in my code, so I could look over them all and look for my own errors first. I've looked at Eclipse a bit--does it include a compiler that wouldn't cut off errors? Or is there another program someone prefers?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic