Hello World program in Java

Notes:

Hello World program in Java Programming Language:

Hello World program in Java: Explained in detail
In this video we understand the essential code required to display Hello World in to the Output window.

package helloworld;
- package helloworld; is the package declaration statement. It tells to the compiler that the underlying class HelloWorld belongs to helloworld package
- By reading package helloworld; statement compiler understands that; it has to create a class file for class HelloWorld within the helloworld package

public class HelloWorld
- public class HelloWorld is the header part of the class HelloWorld definition

public: public is a keyword; It is an access modifier
There are 2 reasons to make the main class public
1. If the class name and file name are same then it is recommended to make that class public
2. It makes the class HelloWorld to be accessible to all other classes in our Java project.

class HelloWorld:
- class is a keyword; it is used to define a class. HelloWorld is a class name. Java is a pure object oriented programming language hence everything must be part of a class.

{}:
- Pair of flower brackets written immediately after the class HelloWorld indicates body of the class HelloWorld and pair of flower brackets written immediately after main() method indicates body of the main() method. It just indicates the beginning and end of a construct.

main() method header: public static void main(String[] args)

main() :
- main is a method. It is the entry point where the execution begins

void: is a keyword
- It indicates main method does not return anything back. It is a return type of main() method in Java

static: is a keyword
There are 2 reasons for main method to be static
1. static members are executed before non static members
2. JVM does not need to create an instance for executing main() method

public: is a keyword; it is an access modifier
- It makes main method to be accessible to all other classes and to the JVM.

String[] args:
- String[] args is an argument to the main method; which indicates args is an array of type string. It is used to receive values of type string from the command prompt.

System.out.println(“Hello World”);
- println is a method; which is a member of the out object; again out is a static member of System class. Dot is a member access operator used to access members of an object or a class.
- System.out.println() method prints the given value to the output window and implicitly moves the cursor to the Nextline so that any subsequent output starts on the new fresh line.
- Sequence of characters enclosed in between pair of double quotations is called a string in Java

Note: Java statements must be terminated by semicolon (;) symbol.