Premium Only Content
#3 Write a First Code in JAVA | Skyhighes | Lecture 3
Ready to bring your Java dreams to life? Let's write your first code!
Here's your step-by-step guide:
1. Open a text editor or IDE:
Choose a comfortable environment for writing code. Popular options include:
Notepad++ (simple text editor)
Visual Studio Code (versatile with Java extensions)
IntelliJ IDEA (comprehensive Java IDE)
Eclipse (another popular Java IDE)
Image of different text editors and IDEs for JavaOpens in a new window
www.differencebetween.net
different text editors and IDEs for Java
2. Create a new file:
Name it HelloWorld.java (or any name you prefer, but keep the .java extension).
3. Type in the following code:
Java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Use code with caution. Learn more
4. Save the file.
5. Compile the code:
Open a command prompt or terminal.
Navigate to the directory where you saved the file.
Type javac HelloWorld.java and press Enter. This compiles your code into Java bytecode.
6. Run the code:
Type java HelloWorld and press Enter. This executes the bytecode and displays the output.
Congratulations! You've just written and run your first Java program!
Let's break down the code:
public class HelloWorld { ... }: This line defines a class named HelloWorld. Classes are like blueprints for creating objects in Java.
public static void main(String[] args) { ... }: This is the main method, the entry point of your program. It's where execution begins.
System.out.println("Hello, World!");: This line prints the message "Hello, World!" to the console.
Now that you've mastered the basics, explore more Java concepts and start building awesome projects!
-
2:24:08
WeAreChange
13 hours agoElon Musk & Donald Trump: The Emergency Halt That Saved Us
89.7K61 -
1:13:11
Flyover Conservatives
1 day agoWARNING! Is Bitcoin CIA-Controlled? – The Shocking Reality of Digital Assets - Clay Clark | FOC Show
40.8K11 -
2:00:37
Space Ice
16 hours agoSpace Ice & Redeye Try To Figure Out Seagal's Most Incoherent Movie
161K7 -
1:00:36
PMG
1 day ago $14.62 earned"Santa Trump is Giving Us Hope - But Will Johnson Stand Strong?"
116K14 -
54:30
LFA TV
1 day agoThe German Strongman’s Arrival Is Imminent | Trumpet Daily 12.18.24 7PM EST
85.6K7 -
2:04:11
Melonie Mac
14 hours agoGo Boom Live Ep 32! Soul Reaver Remastered!
70.6K10 -
39:11
Sarah Westall
12 hours agoDigital Slavery and Playing with Fire: Money, Banking, and the Federal Reserve w/ Tom DiLorenzo
86.7K8 -
1:38:38
2 MIKES LIVE
16 hours ago2 MIKES LIVE #157 ILLEGALS, PROTESTORS AND DRONES!
54.4K2 -
1:01:03
LFA TV
1 day agoTHE LATEST SPENDING BILL IS AN ABOMINATION! | UNGOVERNED 12.18.24 5pm EST
54.5K51 -
1:43:34
Redacted News
15 hours agoBREAKING! WARMONGERS PUSHING TRUMP TO LAUNCH PRE-EMPTIVE WAR WITH IRAN | Redacted News
170K291