Syntax

Java Main Method Syntax

In Java, main method: the entry point of a Java program — public static void main(String[] args) { ... }

Quick Answer

Syntax
public static void main(String[] args) { ... }
JavaSyntax

Main Method

Code example
public static void main(String[] args) { ... }

The entry point of a Java program.

Learn More

How to main method in Java

  1. Open your Java file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Java Main Method Syntax

Use public static void main(String[] args) { ... }.

Related Syntax References

Frequently asked questions

What is the Java syntax for main method?

Use this pattern: public static void main(String[] args) { ... }

Can I copy this Java code example?

Yes. Use Copy code and adapt the example to your program.

Is this Java syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify