Display "Hello World!!!" on console

If you're just getting started with Java, one of the first programs you'll write is the classic “Hello World” example. It’s a simple program that shows how Java code is structured and how to print something to the screen. In this tutorial you'll learn how to print "Hello World!!!" on console.

What You Need

  • A text editor (like Notepad, VS Code, or IntelliJ)

  • Java Development Kit (JDK) installed on your computer

  • Command line or terminal access


Step-by-Step: Writing Your First Java Program

  1. Open Notepad and paste the following code in it.
    class HelloWorld {
        public static void main(String args[]) {
            System.out.println("Hello World!");
        }
    }
  2. Save the file as "HelloWorld.java" in some directory. As an example I have saved it in directory "C:\JavaPrograms"Note that the filename must be same as the classname containing the main method.
  3. Open Command Prompt and go to the directory where you have saved the program.
  4. To compile the Java program use the following command "javac HelloWorld.java".
  5. Finally to execute the program use the command "java HelloWorld". Then you will get the following output

Explanation of the Code

Now let’s break it down:

  • public class HelloWorld – This defines a class named HelloWorld. In Java, every application must contain a class.

  • public static void main(String[] args) – This is the main method, where the program starts.

  • System.out.println("Hello, World!"); – This line prints the text Hello World !!! to the console.



















The following snapshots gives you the detailed view of the first program






Congratulations!

You've just written your first Java program. This simple example is your first step into the world of Java programming.

Comments

Popular posts from this blog

Develop an Android application to display “Hello World!” on screen

Program to design an applet which draws a circle (having color BLUE) inside a triangle (having color YELLOW)

Build a Simple Android App to Display Student Details