HelloWorld Program in Java

  • In Java to build any object, the JVM which is Java Virtual Machine needs a blueprint and that blueprint we call a class. So, Class defines the structure and working of an object.
  • Public keyword is an access modifier which represents visibility. Simply means it is visible to all.
  • Static is a keyword. If we declare any method as static, it is known as the static method. The core advantage of the static method is that there is no need to create an object to invoke the static method. The main method is executed by the JVM, so it doesn’t require to create an object to invoke the main method. Also we can say, so it saves memory.
  • Void is the return type of the method. It means it doesn’t return any value.
  • Main represents the starting point of the program.
  • String[] args is used for command line argument.
  • System.out.println() is used to print statement. Here, System is a class, out is the object of PrintStream class, println() is the method of PrintStream class.

You can watch video for step to step wise guide on how the basic parameters work in Java and can also see how the Hello, World! Program works in java.

Java Program: Hello, World!

public class Hello{
    public static void main(String[] args) {

     System.out.println(“Hello, World!”);

}
}

Remember before you are going to run your first Java program just save it in local computer with your own choice name but the must thing is add extension .java after the file name.

Connect with us: