I've often pondered over this subject. I know the main method has a special signature the JVM looks for, but why is it static?
server_crash
64
Postaholic
Recommended Answers
Jump to PostDunno probly cus thats how they want it to work.
Jump to Posti think static has to do w/ how its accessed
Jump to Post>why is it static?
Primarily so that the JVM doesn't have to instantiate your controlling class to get an entry point into the program.
Jump to PostJava Language specification (second edition) section 12.1.4:
12.1.4 Invoke Test.main
Finally, after completion of the initialization for class Test (during which other consequential loading, linking, and initializing may have occurred), the method main of Test is invoked.
The method main must be declared public, static, and void. It must accept …
Jump to PostThis is 6 years old thread!
All 25 Replies
OurNation
5
Master Poster
Ghost
0
Posting Whiz
server_crash
64
Postaholic
Narue
5,707
Bad Cop
Team Colleague
server_crash
64
Postaholic
Narue
5,707
Bad Cop
Team Colleague
server_crash
64
Postaholic
jwenting
1,889
duckman
Team Colleague
server_crash
64
Postaholic
LunLun
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
server_crash
64
Postaholic
Narue
5,707
Bad Cop
Team Colleague
server_crash
64
Postaholic
OurNation
5
Master Poster
server_crash
64
Postaholic
jwenting
1,889
duckman
Team Colleague
server_crash
64
Postaholic
jwenting
1,889
duckman
Team Colleague
dragony2000
0
Newbie Poster
hooknc
1
Posting Whiz in Training
jwenting
1,889
duckman
Team Colleague
madhav_2k
-1
Newbie Poster
minded
0
Newbie Poster
Taywin
312
Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.