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
The Mike Schwartz Show
3 hours agoTHE MIKE SCHWARTZ SHOW Evening Edition 09-15-2025
5,001 watching -
LIVE
LIVE WITH CHRIS'WORLD
5 hours agoLIVE WITH CHRIS'WORLD - They Just Created 1 Million Charlie Kirks
107 watching -
LIVE
Quite Frankly
6 hours agoStaggering Evil, Official Stories & Open Lines | Rich Baris 9/15/25
764 watching -
1:09:33
TheCrucible
4 hours agoThe Extravaganza! EP: 36 (9/15/25)
154K17 -
1:13:06
Candace Show Podcast
3 hours agoThey Are Lying About Charlie Kirk. | Candace Ep 235
75.9K388 -
1:47:40
Kim Iversen
4 hours agoWas There a Second Shooter in the Charlie Kirk Attack?
46K67 -
DVR
Redacted News
4 hours ago“They’re NOT stopping with Charlie Kirk!” JD Vance TORCHES violent leftists | Redacted
230K100 -
39:45
Kimberly Guilfoyle
4 hours agoCharlie's Legacy and Our Mission | Ep.253
44.6K13 -
10:06
Tundra Tactical
4 hours ago $0.50 earnedWhats The Deal With New Guns In 2025 Part 2
13.8K -
1:13:10
The Amber May Show
5 hours ago $0.74 earnedCharlie Kirk Murder Probe EXPLODES | FBI, FEMA, & SCOTUS Shake the Nation
10K6