Why main class should always be static? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why main class should always be static?

8th Feb 2016, 9:22 PM
Khurshid wali
Khurshid wali - avatar
4 Answers
+ 6
If it were non-static method, jvm creats object first then call main() method that will lead to the problem of extra memory allocation.
13th Aug 2016, 3:08 PM
WPimpong
WPimpong - avatar
+ 1
since execution of program starts from the main method. static methods doesn't require objects to call them
27th Mar 2016, 6:06 AM
Kurra Vijaya Bala subramanyam
Kurra Vijaya Bala subramanyam - avatar
+ 1
to called without instantiate
12th Jun 2016, 9:08 PM
Fatlum Haxhiu
Fatlum Haxhiu - avatar
0
w1rr 0yjl97q
28th Dec 2017, 5:38 PM
Fatlum Haxhiu
Fatlum Haxhiu - avatar