by Dinesh Thakur

Our first program is composed of three logical parts :

1. Definition of the class;
2. Definition of the method main ();
3. Content of the method main ().

Class definition

The first line of our program defines a class named HelloJavaExample. The simplest class definition consists of the keyword class, followed by the class name . In our case, the class is HelloJavaExample.

Definition of method main ()

The second line defines a function ( method) and methods of main (), which a gateway or starting point for the program. each program a Java method starts from main () with the signature :


public static void main(String[] args)


The method must be declared as just illustrated , it should be public, static and void, must have a name and a main list of parameters must have a single parameter of type array String. Places of public and static modifiers can be exchanged. In our example, the parameter is said argument, but this is not optional parameter can have any name . most programmers choose a name args or argv.

If any of the above requirements is not met , the program will compiles , but will not be able to start and will give us a message error because it contained no starting point.

Contents of the main () method

The Code line System.out.println("Hello Java World"); will really work in this program. The text “Hello Java World” is a literal string of characters; that will be appear in output exactly as entered. Any literal string is written between double quotation in Java Programming Language because the string is an argument for a method, and arguments to methods are always appear within parentheses. The dot in System.out.println are used to separate the class, object, and method. The println() requires only one argument. The println() prints a line of output on the screen.

             Anatomy of a Java Statement

In the statement System.out.println("Hello Java World");, out is an object. The out object represents the screen window.

            The Parts of a Typical Class

The print() is similar to the println(). The println() insert a new line after the message prints. While the print(), does not insert a new line; it remains on the same line as the output.


Here is the java code for the program HelloJavaExample :

public class HelloJavaExample

public static void main(String[] args)
System.out.println("Hello Java World");

   Hello Java Example