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 |
---|---|---|
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) |
---|---|---|---|---|
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") | ; |
---|---|---|
Standard method, Print Line | Data for method | End of Statement |