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
Printable View
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
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
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?
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..).