• Post Reply Bookmark Topic Watch Topic
  • New Topic

<identifier> expected and illegal start errors  RSS feed

 
Kyle Tuft
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are those ...(dots) part of the code?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!