Java – Explaination of Hello World program

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

Public:
Type: Access modifier
Description: In the above program using public makes main() method globally available.
Public method specifies from where and who can access the method. Public methods can be invoked by JVM (Java Virtual Machine) from outside of the class, in the same program file or any other java program file.

See Java Access Modifiers or Access Controls

Static:
Type: Keyword
Description: JVM invokes static main() method without instantiating the class which, also, in turn saves the unnecessary wastage of memory while calling object(s) declared for calling the main() method.

Void:
Type: Keyword
Return Type: Void
Description: Void is used to specify that a method doesn’t return anything.

main:
Type: Identifier
Description: JVM looks for main() as the starting point of the java program.

String[] args:
Type: Array of type java.lang.String class
Description: It stores Java command line arguments.

System:
Type: Class
Description: System is a final class in the java.lang package

out:
Type: Variable
Description: Out is a public and static member of the System class and is an instance of java.io.PrintStream

println:
Type: Method
Description: The println is a method of java.io.PrintStream, which prints any argument passed while adding a new line to the output.

Leave a Reply

Your email address will not be published. Required fields are marked *