Understanding Hello World Java Program

Now you are familiar with the Java program.

Understanding Hello World Java Program


Now you are familiar with the Java program. In the last lesson you learned how to compile and run the Java program. Before start hard programming in Java, its necessary to understand each and every part of the program. Lets understand the meaning of  public, class, main, String[] args, System.out, and so on.

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

Class Declaration:

Class is the building block in Java, each and every methods & variable exists within the class or object. (instance of program is called object ). The public word specifies the accessibility of the class. The visibility of the class or function can be public, private, etc. The following code declares a new class "HelloWorld" with the public accessibility:

public class HelloWorld { 

The main Method: 

The main method is the entry point in the Java program and java program can't run without main method. JVM calls the main method of the class. This method is always first thing that is executed in a java program. Here is the main method:

public static void main(String[] args) {



{ and is used to start the beginning of main block and } ends the main block. Every thing in the main block is executed by the JVM.

The code:

System.out.println("Hello, World");

prints the "Hello World" on the console. The above line calls the println method of System.out class.

The keyword static:

The keyword static indicates that the method is a class method, which can be called without the requirement to instantiate an object of the class. This is used by the Java interpreter to launch the program by invoking the main method of the class identified in the command to start the program.

Share on Google+Share on Google+

Understanding Hello World Java Program

Posted on: February 9, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Understanding Hello World Java Program   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Robert Newsome
June 15, 2011

Why is it every, I mean every tutorial fails to address the word "void" when they explain writing methods.
June 14, 2011

Im a biginner of java,now iam just start to learn java.I think rose india site will help to steady easily.I lerned some chapters and i can feel so easy to compared other tutorials,your program explanation could help me.This explanation of each syntax is the main advantage of rose india.Any way i belive it will help me thanking u.
July 12, 2011

ok very good
August 29, 2011

it is hard to learn java
Manish kumar
September 1, 2011
about main methode

we can execute java program without main methode....... eg.... class First { static { System.out.println("this is executing without main methode....."); System.out(0); } }
mamta bangari
September 8, 2011
want to learn java

nice site for learning java
November 7, 2011
programming in java

what does invoking mean?