Hello World Program in Java

In this section, we will learn how to compile and run first Hello World program in java. We will also discuss about the parameters used in java program.

You can also refer our video tutorial for same.

So let’s start with this tutorial :

Hello World Program in Java

  Prerequisite : 

To compile and run the java program , there are following pre-requirement :-

  • JDK should be installed on your system.
  • If you don’t have installed JDK on your system, download the JDK and install it.
  • The path of bin directory should be set.
  • IntelliJ IDEA IDE should be installed on your system.

Now open your IntelliJ IDEA IDE and write the following code:-

Class First
{
Public static void main (String[] arg)
{
System.out.println (“hello world”);
}
}

Do You Know ?
We can write the main method as: –
Public static void main(String… args)

Description of above program :

  1. Class:-  Class is a keyword which is used to define a class.
  2. Public:-  public is a access modifier which tell us that this method can be access by anyone.
  3. Static:-  static is a keyword. We can define any method as static.If we define a method as static then we don’t need to create the object in order to access that method. Since the main method is static Java virtual Machine can call it without creating any instance of a class which contains the main method.
  4. Void:-  void is the return type which indicate that it does not return any value.
  5. Main:-  main method is the entry point of any java program.
  6. String[] arg:-  String[] arg is the command line argument. We will discussed it later on.
  7. System.out.println:-  This whole line is used to print the statement. In this, System is a final class in java.lang packag., out is the object of  System class and is type of PrintStream class and println is the method of PrintStream.
Do You Know ?
We can put a semicolon at the end of class such as:
Class Abc
{
Public static void main(String… args)
{
Syste,.out.println(“hello friends”);
}
} ;

If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.

Thank you 🙂 Keep Learning !

Leave a Comment

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