The Hello World Application

The best way to learn a programming language is to jump right into it and see how real programs work. The first Java program we are going to see now is the famous Hello World program.

Hello World Program

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

Type the above code in any text editor and save it in a file named HelloWorld.java

Next at the command line you type

C:\>javac HelloWorld.java

The above command will compile the program and will generate bytecode in a file named HelloWorld.class. To run the application at the command line you type

C:>\java HelloWorld

Your application will run and you will get the following message printed on the screen.

Hello World

There are a couple of important points you have to note in the above example. First and foremost, the entire application is a class, in this case class HelloWorld the function

public static void main(String args[])

is a member function, in this case the one and only member function of class HelloWorld. Java is highly object oriented. Java program may contain one or more than one class.

The Java language statement

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

prints the Hello World message on the screen.

It's very calm over here, why not leave a comment?

Leave a Reply