Why We Write Public Static Void Main
When Java Runtime Starts, There Is No Object of the Class Present. That’s Why the Main Method Has to Be Static So That Jvm Can Load the Class into Memory and...
When java runtime starts, there is no object of the class present. That’s why the main method has to be static so that JVM can load the class into memory and call the main method. If the main method won’t be static, JVM would not be able to call it because there is no object of the class is present.
Why do we use public static void main?
Main(String[] Args) – main is a method which accept the string array in command prompt . public means You will access anywhere. Static it mainly used for main method because we can call main methodonly one time which is fixed. Void means it doesn’t have any return type.
What is public in public static void main?
Explanation: Every word in the public static void main statement has got a meaning to the JVM. Public: It is an Access modifier, which specifies from where and who can access the method. Making the main() method public makes it globally available.