Your First Java Program

shashank balaji
2 min readMay 23, 2020

--

When I wanted to learn java, I always struggled with finding the right Software for it. If you are too, then this blog is for you!

To start, I recommend Bluej. You can download it by going to https://www.bluej.org, scrolling down, and selecting your operating system.

Next, open the software then click on “project” then on “new project”, name your project and a new window will open. Now you click on the “new class”. Name your class “Addition” and press “ok”. Right-click on the small green box and select “open editor”. Another window will open.

Now comes the coding part of it! Delete everything except for :

public class example
{

Then for your first program, we will do addition. After the above line, go to the next line and leave 1 tab space (4 spaces) and type:

public static void main()
{
//declaration
int a;
int b;
int sum;

//initialization
a = 20;
b = 30;

//add a and b and store in sum
sum = a + b;

//display
System.out.println(“the sum of “ + a + “ and “ + b + “ is = “ + sum);

}

}

Be aware of the indentations!!!!

I recommend you not to copy-paste the program but type it on your own!!

There you have it! Your first Java program!

Good luck!!

-Shashank Balaji

--

--

No responses yet