Premium Only Content

Java "Hello World"
Java Tutorial 1: Printing "Hello, World!"
This tutorial covers the very first step in Java programming: printing "Hello, World!" on the screen. This simple program introduces the structure of a Java program and demonstrates how to display text in the console.
Writing the Code:
In your HelloWorld.java file, type the following code:
java
Copy code
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Understanding the Code:
public class HelloWorld: Defines a class named HelloWorld. In Java, every program must have at least one class, and the file name must match the class name.
public static void main(String[] args): This is the main method, the entry point of every Java application. When you run the program, this method is executed.
System.out.println("Hello, World!");: This line prints "Hello, World!" to the console. The System.out.println method outputs text to the screen, followed by a new line.
Compiling and Running the Program:
Compile the code by opening a terminal, navigating to the folder where HelloWorld.java is saved, and running:
bash
Copy code
javac HelloWorld.java
This command compiles the code and creates a file named HelloWorld.class.
Run the program with:
bash
Copy code
java HelloWorld
You should see the output:
Copy code
Hello, World!Writing the Code:
In your HelloWorld.java file, type the following code:
java
Copy code
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Understanding the Code:
public class HelloWorld: Defines a class named HelloWorld. In Java, every program must have at least one class, and the file name must match the class name.
public static void main(String[] args): This is the main method, the entry point of every Java application. When you run the program, this method is executed.
System.out.println("Hello, World!");: This line prints "Hello, World!" to the console. The System.out.println method outputs text to the screen, followed by a new line.
Compiling and Running the Program:
Compile the code by opening a terminal, navigating to the folder where HelloWorld.java is saved, and running:
bash
Copy code
javac HelloWorld.java
This command compiles the code and creates a file named HelloWorld.class.
Run the program with:
bash
Copy code
java HelloWorld
You should see the output:
Copy code
Hello, World!
-
LIVE
GloryJean
55 minutes agoDominating The Sniper Role 🖱️ 6.7 K/D | Duos w/ Spartakus
12 watching -
LIVE
BigTallRedneck
54 minutes agoBRRRAP PACK VS ANYBODY!!
36 watching -
1:09:21
TheCrucible
3 hours agoThe Extravaganza! Ep. 24 (8/20/25)
56K7 -
1:18:42
Kim Iversen
3 hours agoUFO Base Area 51 Catches Fire… Is It a Massive Cover-Up?!
29.5K49 -
1:51:18
Redacted News
4 hours ago"There will be consequences!!!" Trump issues big threat to Putin ahead of peace summit | Redacted
97.8K83 -
53:14
Candace Show Podcast
4 hours agoThe MOST MORAL Blackmail In The World | Candace EP 231
51.4K134 -
1:11:28
vivafrei
5 hours agoMatt Taibbi Getting "Westfalled"? Kathy Hochul Fighting for Illegals! Mamdani Minority Report & MORE
98.2K57 -
2:03:39
Pop Culture Crisis
5 hours agoWTF Happened to Miley Cyrus? HARRY POTTER Set Images, Sydney Sweeney Hater EXPOSED | Ep. 901
42.5K21 -
10:17
MattMorseTV
6 hours ago $6.96 earnedTrump's DOJ just DROPPED a NUKE.
47.9K44 -
11:07
Politibrawl
12 days agoRepublican rising star DESTROYS theatrical Democrat in front of the entire world
85.2K30