• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Illegal start?

 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do I get an illegal start at public in getPrice()?

 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the closing brace of setPrice() is missing.

A good programmer's editor or IDE would point out this kind of problem very quickly. A simple editor that knows how to do Java code formatting would work well enough -- the missing brace would mess up the formatting.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually you get errors like that when there are mismatched braces or other problems with punctuation in the lines before the line where you get the error.
 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand, doesn't it have a closing brace?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at setPrice(). The last character that clearly belongs to it is indeed a closing brace; but it's the closing brace of an "else" clause. There should be another one to end the whole method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic