First program (Lesson 2)

Done setting up the Netbeans IDE? Ready to code? Here’s our first program in Java.

To start, first we will have to  create a new project.
1. Select File >> New Project

2.  In Categories section, select Java and in Projects section, select Java Application and click on Next.

2. In the project name category, type the project name and make sure that create main class box is checked. Click on finish.

3.  In the screenshot below see the place where you have to start coding.

4. Type in

System.out.println(“Hello World”);
This is your actual statement. This statement will display Hello World on the screen. You can write anything  instead of Hello World to display it on the screen (Make sure to put it inside double quotation marks). Also note that Java statements are case sensitive. It means that System and system are not the same.
5. Your  program will look like something as shown in the picture below. Click on the Run Project button to display the output.

6. The IDE will show the output for your first program.

Following is the full code for your first program that is typed currently in the IDE:

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

You can use System.out.println statement as many times as you wish to display multiple lines of text from your program.

Practice Corner:
Write program to display 10 lines about you.

Bonus Tip:
You can directly click the new project button instead of going to file>>new project. This will make creating projects even faster.

2 thoughts on “First program (Lesson 2)”

Leave a Comment