Every Java program must have one main method. The main method is the first method which the Java Virtual Machine executes. The main method then calls the other methods, as they are needed.

It is good programming practice to maintain a very small main method and to move all possible code into other methods.

Here is the main() method from a Java program which prints "Hello World":

 public static void main (String[] args) {
   // This Java program prints "Hello World!"
   System.out.println{"Hello World!");