Hello World

public class HelloWorld {

public static void main(String[] args){
System.out.println(“Hello world”);
}
}

public class HelloWorld – is a class file that you will use to start programming your java program. Within the ‘{}’ of HelloWorld class is where all the relevant codes of that class file/program will be in.

public static void main(String[] args) – we need this method as a default method because Java needs to know where to start the execution the codes. Without this the Java will not know. This line is also known as a method header named ‘main’ and the code inside the ‘{}’ is known as method body.

System.out.println(“Hello world”); – the system outputs by printing the “Hello world” message. Print is a built-in method and helps to print out the statement inside the ‘()’.

HelloWorld
First program codes with comments

Leave a comment