About static confusion | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

About static confusion

why main mehod needs to be static? Is it mandatory? Are there any other methods that needs to be static and why? Pls can anyone explain with a example.

6th Sep 2016, 3:22 AM
Deekshith Banjan
Deekshith Banjan - avatar
2 Antworten
+ 2
and static method has better performance than object method
6th Sep 2016, 7:50 AM
Yousha
Yousha - avatar
+ 1
It has to be static cause there is no instance, I mean, an object pre-written; we only have the class, the program it's just about to start. Basically, main method need's to be mandatory static.
6th Sep 2016, 5:38 AM
Rodrigo Blancas
Rodrigo Blancas - avatar