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!
-
1:06:19
BonginoReport
10 hours agoManhunt Underway for Charlie Kirk’s Assassin - Nightly Scroll w/ Hayley Caronia (Ep.132)
302K238 -
1:11:42
Flyover Conservatives
18 hours agoStructural Architect Destroys 9.11 Narrative... What Really Happened? - Richard Gage AIA | FOC Show
92.6K16 -
1:51:14
Precision Rifle Network
14 hours agoS5E1 Guns & Grub - Charlie Kirk's "sniper"
53K17 -
13:09:12
LFA TV
21 hours agoLFA TV ALL DAY STREAM - THURSDAY 9/11/25
414K93 -
1:01:56
The Nick DiPaolo Show Channel
11 hours agoDems + Media Killed Kirk | The Nick Di Paolo Show #1792
128K120 -
1:35:10
LIVE WITH CHRIS'WORLD
13 hours agoLIVE WITH CHRIS’WORLD - WE ARE CHARLIE KIRK! Remembering a Legend
39.8K7 -
50:24
Donald Trump Jr.
12 hours agoFor Charlie
402K495 -
2:05:22
Quite Frankly
14 hours agoTipping Point USA? & Open Lines | 9/11/25
80K8 -
1:04:09
TheCrucible
10 hours agoThe Extravaganza! EP: 35 (9/11/25)
110K35 -
1:19:43
Dr. Drew
14 hours agoCharlie Kirk Assassination: 24 Hours Later, What We Know About The Utah Valley University Shooting w/ Salty Cracker, Free Speech Activist Douglass Mackey & Experts – Ask Dr. Drew
118K37