Forums Register Login

public static void main

+Pie Number of slices to send: Send
Can you please tell me how to modify this code (taken directly from the SCJP Sun Certified Programmer for Java 6 Study Guide (Exam 310-065) book) so it executes?
I keep getting the error message java.lang.NoSuchMethodError: main
Exception in thread "main" when I try to execute the examples from this book. I am told it's because the code doesn't include the main method, but I haven't found any information on what the correct syntax is for including the main methods and the other methods in the class. Here is the code -- any advice on how to modify it would be appreciated. Other examples that only include the main method have worked when I've executed them so I don't think this is an issue with my Classpath.

class Zoo {public String coolMethod(){
return "Wow baby";
}

}
+Pie Number of slices to send: Send
you can't write in the prompt java class if this class don't have the method main.
+Pie Number of slices to send: Send
Thank you for your reply. I understand that it needs the method main. My question was how should the code be modified so that the main method is included? The example I gave showed a class that contained the method called coolMethod. How do I include this in the class as well as the main method? I need to know the syntax and I can't seem to find an example of this anywhere.
+Pie Number of slices to send: Send
 

Originally posted by Lutin Verasoi:
Can you please tell me how to modify this code (taken directly from the SCJP Sun Certified Programmer for Java 6 Study Guide (Exam 310-065) book) so it executes?
I keep getting the error message java.lang.NoSuchMethodError: main
Exception in thread "main" when I try to execute the examples from this book. I am told it's because the code doesn't include the main method, but I haven't found any information on what the correct syntax is for including the main methods and the other methods in the class. Here is the code -- any advice on how to modify it would be appreciated. Other examples that only include the main method have worked when I've executed them so I don't think this is an issue with my Classpath.

class Zoo {public String coolMethod(){
return "Wow baby";
}

}



Every program has to have at least one main method.

One way of doing this is (save as TestZoo.java):
/

You probably should be starting with a less advanced resource for learning the language than the exam study guide... you need to know the basics first.
+Pie Number of slices to send: Send
Can you recommend one that would be a good precursor to the exam guide?
+Pie Number of slices to send: Send
 

Originally posted by Lutin Verasoi:
Can you recommend one that would be a good precursor to the exam guide?


Head First Java by Kathy Sierra and Bert Bates.
+Pie Number of slices to send: Send
core java is good guide too!
Climb the rope! CLIMB THE ROPE! You too tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 797 times.
Similar Threads
StringBuilder
Design Review part III
need help on main method!!
Why the remote client code must provide all the public methods of the Data class?
Invoking methods within the same class and from different classes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:41:16.