simple main function doubt
posted 6 years ago
You need the "public" so that code outside the class (namely the JVM's class loader) can call the function. You need the "static" so that the function can be called without an object (since it is not clear how one would instantiate the class, as there might be multiple constructors). It needs to be called "main" because the JVM has to have something to search for, and "main" is the canonical name. And it has to have String as its argument so that the JVM can pass in the command line arguments.