Skip to content

A simple Java program

Estimated time to read: 1 minute

A simple Java program with main()

HelloWorld.java
public class HelloWorld {
 pubic static void main(String[] args) {
  System.out.println("Hello World");
 }
}

Class

public class HelloWorld {}
public class HelloWorld
Visible to the runtime Type Name

To be recognisable to Java, it must be in a file named 'HelloWorld.java'.

Class naming convention: words are separated by upper case letters.

Note

Java is case sensitive!.

Signature

 public static void main (string[] args)
public static void main (string[] args)
Visible to the runtime Not reliant on having an instance or object providing data. All entrypoints are static. The function / method does not return anything The "main" entry point of the function Arguments can be provided from the command line. These are added in, in this instance, as a string array.

Function / Method Statement

System.out.println("Hello World");
System.out.println ("Hello World") ;
Standard method, Print Line Data for method End of Statement

File Structure

- src
 - io.entityfour.academy
  - HelloWorld.java