| Author |
why is main method always static??
|
Ashok George
Ranch Hand
Joined: Mar 25, 2005
Posts: 87
|
|
hi all!! i am very new to java and object oriented programming but studying for SCJP yesterday while going through an article i was wondering Why is the MAIN METHOD always Static!!! can any 1 help !!!
|
 |
Mahesh Rana
Ranch Hand
Joined: Sep 05, 2001
Posts: 139
|
|
|
Take a look at public static void main
|
SCJP2
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
Java has to call the main method to start your program. If main were not static, java would have to first create an extra instance of the class that contains main. If that class lacks a no-arg constructor, java would have no way to do that. Keeping main static avoids this complication.
|
Mike Gershman
SCJP 1.4, SCWCD in process
|
 |
Ashok George
Ranch Hand
Joined: Mar 25, 2005
Posts: 87
|
|
thanx a lot!!! ... thats really helped me in clearing stuff !!! thanxa lot adios!!! and may god bless u ppl !!!
|
 |
 |
|
|
subject: why is main method always static??
|
|
|