• Post Reply Bookmark Topic Watch Topic
  • New Topic

missing method body error  RSS feed

 
Shhailesh Joshi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Welcome to the Ranch!

It's easier to find the error if you format the code (I've just done that for you), but have a look at the end of line 4. Is that how you define a method?

(And why have you got so many braces {..}? The ones between lines 8 and 21 aren't really doing anything at the moment).
 
Shhailesh Joshi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you.but javac suggest to put semicolon there.i am beginner.please give further info.
 
Shhailesh Joshi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
will you please enlist the errors and solutions you find in my code.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ShaileshHackz Joshi wrote:will you please enlist the errors and solutions you find in my code.

We don't work that way. you should not expect somebody to just fix your code for you. We'll help you learn how to figure it out so that next time you can do it on your own.

Remember, javac is just GUESSING what you need. it's not as smart as you.

My suggestion would be to start over. Write as little code as you can before compiling. If you insist, you can just comment out every line here, and try un-commenting them one at a time, but that can actually be harder.

So...what is the ABSOLUTE minimum you need to compile (and do something that lets you know it works)? I always start with this:



I compile and run that. Once I know it works, I may add a new line or two AT MOST:



Compile and test that before moving on. And keep going like that until you've added back in all your original code. If you only add 1-2 lines and you get an error, you know it has something to do with those one or two new lines.
 
Shhailesh Joshi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Shhailesh Joshi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but can you tell me whats the difference between the cod i written before and the code now.i think no difference.then why it did'nt run before.THIS IS MY NEW CODE.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shhailesh Joshi wrote:but can you tell me whats the difference between the cod i written before and the code now.i think no difference.then why it did'nt run before.THIS IS MY NEW CODE.



Your new code defines the method local variables in a valid location. Your old code defines it where the compiler expects the body of the method to be, hence, the complaint.

Henry
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your original code had this:


your revised code has this:


the difference is pretty obvious.
 
Shhailesh Joshi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks buddy,,,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!