Start Coding Now

public static void main(String[] args) - Explained

Detailed explanation of the Java main method syntax. Understand what public, static, void, main, and String[] args mean.

Breaking Down main()

public static void main(String[] args)

  • public: Access modifier. JVM needs to call it from outside.
  • static: Can be called without creating an object of the class.
  • void: Returns nothing.
  • main: The name of the method searched by JVM.
  • String[] args: Command line arguments.

Can we change it?

  • Order: static public works.
  • Args: String args[] or String... args works.
  • Name: Must be main.

Frequently Asked Questions