In this tutorial you will learn about the Java Program to Print Hello World and its application with practical example.
Java Program to Print Hello World
In this tutorial, we will learn to create a Java program that will Print Hello World in Java programming.
Prerequisites
Before starting with this tutorial, we assume that you are the best aware of the following Java programming topics:
- Operators in Java Programming.
- Basic Input and Output function in Java Programming.
- Basic Java programming.
Printing a message:-
Message passing is a very important feature for object-oriented programming. Here in this program, we will print the message to the user for hello world.
Algorithm to Print Hello World in the output:-
1 2 3 4 5 6 7 |
1. Declaring the variables for the program. 2. Defining the input value for the variable in string format. 3. Printing the data taken in input from the user in string format. 4. End program. |
Program to Print Hello World
The string is a collection of characters in Java programming. The string is used for sending messages on the screen. In Java programming, we can take the input from the user in string format. In this program, we will define input in string format. The second will print the string “Hello World” with the help of a small program. The String is the most useful datatype in any programming language. The message passing in any program is very important. It is also a part of the object-oriented programming (OOP’s) concept.
Program to Print Hello World:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Program to print the hello world program in java import java.util.*;//Importing the package for the program. public class HW {//Creating the class for the program in public type //Body of Main function of the program public static void main(String[] args) { //Declaring the required variable for the program. //String type variable to hold message. String s ="Hello, World!"; //Prinint the hello world to the user //Using the System.out.println(); System.out.println(s); } } |
Output:-
In the above program, we have first initialized the required variable.
- s = it will hold the input string value from the user.
Importing the util package for the program.
Printing the data in the output in the string format.
The Program Code for the main method.