File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Error" Watch "Error" New topic
Author

Error

Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Ok I have a question about the following code. I keep getting errors about the "static double findCharge(int Kwh)" line. Does something need to be before that to make it compile like public static int( ) ??? Help anyone?

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24081
    
  15

Hi Holly,

You've "nested" the definition of findCharge() inside your main() method, and that's not allowed. Method definitions all have to be at the "top level" of a class, enclosed only by the class X {...} set of braces.


[Jess in Action][AskingGoodQuestions]
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
So do I just move the static double part of the code or the whole while loop? Sorry I am sure that is a dumb question
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1348
You need to move the method "static double part of the code" out of the while loop. In the while loop it looks like you'll need to call that method.
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Ok I understand..but I am still a little sketchy as to how to write that...any more help? I know it is probably hard to help with this problem. I don't quiet understand yet. Thanks again I really appreciate it.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Error
 
Similar Threads
How close am I in getting this program right?
Review
Random Access Problem
Error - not a statement
Program Output not working