• 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

Metthod within method need sloving

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to correct the method within a method at line 267
please can someone slove it ?

 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first thing you should do is to indent your code so the { symbols and the } symbols match up vertically. Then, since the error is caused because you don't have enough of one or the other kind of those symbols, it should be easier to find out where you missed one. If you are using an IDE like Netbeans or Eclipse then there's an option you can take to reformat your class.

As it is you have several hundred lines of code which is less readable than it should be. This problem is the consequence of having unreadable code.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

You should also write code from outside in, rather from top to bottom, which reduces the risk of such mistakes.
 
Teh Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ive counted every { and } and they are equal but the thing is that i am nesting a method within a method and have no idea how to sort it out
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that all in the main() method? Good grief! Any method that long ought to be divided into several methods.
Also that whole thing is non object-oriented; you ought to have classes for CPU, memory, etc.
 
Teh Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I only learnt this in like 4 weeks at colllege so im not the best :/
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Teh Singh wrote:Ive counted every { and } and they are equal...



Sure, but they are in the wrong order. I still suggest you format your code better. Even if you find your problem now, it will be easy for you to break it again and have the same problem.
 
Teh Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem is i aint learnt that far yet in college

and have half term but trying to finsih my program and have no idea how to have seperate classes for them etc.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is why you don't write 300 lines of code before you compile. My guess is that you have something like this:



You'll notice I have the correct number of curly braces, but this code would be invalid. You have to close one method before you start the next. So my above example would be correctly written as this:
 
Ranch Hand
Posts: 47
Netbeans IDE Eclipse IDE Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Teh Singh wrote:Problem is i aint learnt that far yet in college

and have half term but trying to finsih my program and have no idea how to have seperate classes for them etc.



Your main method is from line 5 till 393, within this method you have another method printheader between line 267 and 276. That's causing the error. If you put the method outside of main and use it you can remove 87 lines of code from the main .

regards,
Ben
 
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about the semi-colon at the end of line 267, before the {?
 
Ben Ooms
Ranch Hand
Posts: 47
Netbeans IDE Eclipse IDE Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Greg Brannon wrote:How about the semi-colon at the end of line 267, before the {?



Your totally right, I fixed that one and forgot to mention it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic