|
-
September 29th, 2011, 09:08 PM
#1
main method
There must be some expceptoins when it comes to main methods correct? Like there are certain circumstances where main methods aren't nessasary or needed. I would be very appriciateive if someone could lay them out for me.
-
September 29th, 2011, 09:53 PM
#2
Re: main method
your question is a little vague. And the answer would be enormous. What exactly are you trying to accomplish?
-
September 29th, 2011, 10:13 PM
#3
Re: main method
Okay sorry haha..
Revamped question:
Can you have a class without a main method (that will compile, and work)?
-
September 30th, 2011, 12:14 AM
#4
Re: main method
 Originally Posted by kolt007
Can you have a class without a main method (that will compile, and work)?
Sure, you only need one class with a main method. The main method is the so called program entry point, that is where the program starts.
But you can have several main methods (each in a different class) if you wish. Then the program will have many entry points and you must select which one you want when you start the program.
-
September 30th, 2011, 09:14 AM
#5
Re: main method
You need to have the standard main method in any class you try to start by using the java command:
java ThisClassMustHaveMainMethod
Norm
-
October 1st, 2011, 11:51 AM
#6
Re: main method
public static void main(String args[]) method is only needed to run the program , there is no need for compiling a class. in java an empty class is also valid and compile
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|