Java: Hello World

Java is becoming an important language for every programmer to know. It is key to creating platform independent software. In my opinion, Java will continue to play a greater role in enterprise software development.

Those who are computer science majors will recognize the “Hello World” application as the traditional “first application” that a programmer learns. Every time you learn a new language, the books almost always start with hello world!

I will start with the code, then explain:

Java Hello World

This would all be contained in a file called “”

public class HelloWorld{

This line defines the name of the program (HelloWorld). If you think of a class as a mini program, than this line is the name of the program. It also tells us that the type of class it is (public).

Note: The open curly bracket, “{” also has a closing curly bracket to match it. The closing curly bracket is found at the end of the class. Every time an open curly bracket is created, a closed bracket must be placed somewhere later in the file.

public static void main (String[] args){

This is a line that every java programmer can eventually recite in their sleep… Backwards and Forwards! Almost every Java program will begin with this line.

This line is actually creating something called a method. Think of a method as a task that a computer program can do. If this program were human, it might have tasks such as walk, eat, read, talk, etc. In the same way, a computer program has certain tasks it can do. Inside the curly brackets, we will tell how the method works.

This method is called “main.” The words before “main” are the descriptions as to how the method operates. The “String[] args” inside the parentheses actually serves as a way to pass a set of data to the method. You will learn more about this in future tutorials.

System.out.println(“Hello World”);


This is the meat and potatoes of the program. It’s what really makes the program have purpose. This is a very basic command, telling the computer to output “Hello World” onto the screen.

The main method only contains this one statement, but it could include several. This is just for demonstration purposes, so utility is not our goal. Each statement must end with a semicolon. Once the block of statements is complete, you close the curly brackets.

Now, you just need to compile and run your program, but I am saving that for tomorrow!

One thought on “Java: Hello World

Leave a Reply