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
7 hours agoManhunt Underway for Charlie Kirk’s Assassin - Nightly Scroll w/ Hayley Caronia (Ep.132)
254K175 -
1:11:42
Flyover Conservatives
15 hours agoStructural Architect Destroys 9.11 Narrative... What Really Happened? - Richard Gage AIA | FOC Show
54.8K13 -
1:51:14
Precision Rifle Network
10 hours agoS5E1 Guns & Grub - Charlie Kirk's "sniper"
31.2K11 -
13:09:12
LFA TV
18 hours agoLFA TV ALL DAY STREAM - THURSDAY 9/11/25
398K91 -
1:01:56
The Nick DiPaolo Show Channel
7 hours agoDems + Media Killed Kirk | The Nick Di Paolo Show #1792
113K92 -
1:35:10
LIVE WITH CHRIS'WORLD
9 hours agoLIVE WITH CHRIS’WORLD - WE ARE CHARLIE KIRK! Remembering a Legend
31.4K3 -
50:24
Donald Trump Jr.
9 hours agoFor Charlie
389K445 -
2:05:22
Quite Frankly
10 hours agoTipping Point USA? & Open Lines | 9/11/25
75.1K5 -
1:04:09
TheCrucible
6 hours agoThe Extravaganza! EP: 35 (9/11/25)
105K28 -
1:19:43
Dr. Drew
11 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
113K33