why we need public static void main (String[] args) in java

There’s no object to call main on, so main should be static. Public so that it’s accessible outside the class. It needs to accept the arguments that the program was started with. It should be named main because that’s what gets called at program start.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.