Writing Your First “Hello World” Program in Java

java hello world

How to create your first Java Program

Welcome to my blog about Java! Today I will be taking you through how to print Hello World in Java programming language which is quite easy.

Advertisements

You don’t need to be very good in Mathematics before you can start writing programs, you just have to be committed to learn and then write along the way. This way, programming in Java becomes easy for you.
However, you’re not on this page to become motivated. Let us take a look at how you can create a Hello World program in Java. Before we start writing the program together, here are what you’ll need to successfully write and run a simple Java program:

– Java IDE (Eclipse, Netbeans or Blue J) – I use Blue J and it’s quite advanced so I’ll recommend you download Netbeans and the Java SDK.
– Your Laptop
– Your time

⇒Join us on Telegram for more Sure and Accurate football-winning tips every day...click here

And that is all – So let’s get started with writing your first java program.

Advertisements

java hello world

Take a close look at the image above you, it runs two programs at the same time. I purposely did this so as to make things very easy for you to understand.

1. The first program will print out “Hello World ” after compiling
2. The second program will divide X by Y and print out C where the answer is stored in the program.
Here we go; to create a new java Program, the first thing to do is to create java class, like this:

create java class


Public class NameOfClass{

}

Then we declare the type of program we want to run by passing a method. I kinda don’t know how to explain this part but I’m very sure in every program, you’ll write a method for your program to run and it is usually written like this:


public static void main(String[] args){

}

You will write this code above after declaring your java Class and inside this method is where you’ll write your first java program to print Hello World.
Compared to other languages like JavaScript where you will print to the console, java is quite different even though its syntax is closely related to other Object-Oriented programming languages. To print out a String in java, here’s how to write it out:


// My First Statement – This is a comment, disregard this

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

The above line when written inside the java method prints out “Hello World” and then we’ve successfully written your first java program. Isn’t that amazing? Just like that, you kick-start learning with Java.

After the whole learning, this is how your program should look like:


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

/*
* This is my first java
*
*/

Remember you owe your own learning and then take note that a single comma or parenthesis could make your java program fail to run. So it is advisable to keep calm and code on.

Do you like this article on how to print Hello world program in Java and what next would you love me to teach you next? Let me know in the comment box below.
You’re an amazing reader!

Leave a Reply

Your email address will not be published. Required fields are marked *