Print "Hello World" in JAVA
Que: Print "Hello World" in JAVA
Introduction
If you are starting programming with Java, the first program you usually learn is the Hello World program. It is a simple program used to understand the basic structure of Java code and how a program runs.
This example prints “Hello World” on the screen and helps beginners understand the basic syntax of Java.
Steps:
- Open Bluej and click on "New Class".
- Then open a dialog box, write name of the class and press OK button.
- Now right click on the file name and click on "Open Editor".
- After open editor, write your code and click on "Compile" button. If there any error shown then correct it and compile again.

- Close the editor. Now right click on file name and choose "void main(String arg[])" to run.
- You can see another dialog box, click on "OK" button and output(Terminal) will be shown.
Explanation of the Program
-
1.
public class HelloWorld-
In Java, every program must be inside a class.
-
HelloWorldis the name of the class.
2.
public static void main(String arg[])This is the main method where the execution of a Java program begins.
-
public → Access modifier that allows the program to run from anywhere.
-
static → Allows the method to run without creating an object.
-
void → Means the method does not return any value.
-
main() → The starting point of the program.
-
String arg[] → Used to receive command-line arguments.
3.
System.out.println("Hello World");-
System→ A built-in class in Java. -
out→ Output stream. -
println()→ Prints text and moves the cursor to the next line.
This statement prints Hello World on the console.
😎If you have any doubts or questions about this program, please leave a comment in the comment section. I will try to respond as soon as possible.
For the latest updates, Java notes, and helpful programming tips, make sure to join my WhatsApp Channel. -





Comments
Post a Comment