|
-
Nov 18th, 2002, 07:53 AM
#1
Thread Starter
Member
How come 'private static void main()' works?!
Since, I have some basic exposure to Java, I find this rather curious! Unless main method is 'public' how is the class instantiated?? Anybody answers?
Sujala
-
Nov 18th, 2002, 08:32 AM
#2
As far as I understand it because it's static the class
does not have to be instantiated to use Main or ant other
static methods
-
Nov 18th, 2002, 09:41 AM
#3
Thread Starter
Member
No no
No no, the class is not instatntiated to access the main method. Its the other way round, the main method is used to instantiate the class. Since the main method is 'static' it can be accessed from the class only, i.e. an instance of the class is not required to access it. But my qs. is if the method is 'private' how can it be called from outside the class?
-
Nov 18th, 2002, 09:53 AM
#4
PowerPoster
When the application is executed, the CLR searches the module(s) for the application entry point, whether or not the Main() method is private or public does not matter (I read this in a book, so you may want to test..).
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
|