why main class should be public static
They are public because they must be accessible to the JVM to begin execution of the program. Main is the first method that would get executed in any class. They are static because they must be available for execution without an object instance.you may know that you need an object instance to invoke any method. So you cannot begin execution of a class without its object if the main method was not static.hey are public because they must be accessible to the JVM to begin execution of the program. Main is the first method that would get executed in any class. They are static because they must be available for execution without an object instance.