As we know that the main
method is the entry point of the java program as described in the following resources:
Why main() method is needed in java main class?
Why should main be present in a Java class? [duplicate]
If this is the case then why we need to wrap the main
method in the class if the main
method is the entry point?
What is the role of the class
which wraps the main
method?
In Java, there's no way to have a method without an enclosing type. You need a class, an interface, an enum, etc. to be able to declare and/or implement a method. This is just how it works.
Even when you start a Java program, you specify the name of the class containing the main method. You don't just run arbitrary statements.
In other words it's about the program structure rather than about a specific role played by the class around the main method. And you can even use an interface instead of a class in recent versions of Java.