Write a program to print "Hello World" in java

class HelloWorld
{
   public static void main(String[] args)
   {
     System.out.println("Hello, World!");
   }
}

Output

Hello, World!
 

Explanation

public- Here public is an access specifier which allows thhe main method to be accessble everywhere.
static- static helps main method to get loaded without getting alled by any instance/object.
void- void clarifies that the main method will not return any value.
main- It's the name of the method.
String[] args- Here we are defining a String array to pass arguments at command line. args is the variable name of the String array. It can be changed to anything such as String [] a.
System - System is a final class in java and it is available in java.lang package.
Out - Out is an object reference of PrintStream class i.e out is a type of PrintStream class. Which is defined in System class as public, static and final.
println- is a method of java.io.PrintStream. This method is overloaded to print message to output destination.