"A rose by any other name would smell as sweet," but main by any other name would not. Just because a method has the name "main", that
doesn’t make it the entry point to an application.
In Java versions prior to Java 25, the main method must have a specific signature to serve as the application entry point: it must be public
static void and accept a single String [] as an argument.
Starting with Java 25, the requirements for main methods have been relaxed. The main method can now be:
String [] parameterUsing main for anything other than an application entry point can be confusing to developers unfamiliar with Java, as the method name
strongly suggests it is the starting point of execution. To avoid this confusion, methods with different purposes should be given other names.
public void main(String arg) { // Noncompliant
// ...
}
void main(String [] args) { // Compliant Java 25 instance main
run(args[0]);
}
public void run(String arg) { // Renamed
// ...
}