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!
-
58:14
theDaily302
16 hours agoThe Daily 302- Tim Ballard
47.8K2 -
13:22
Stephen Gardner
10 hours ago🔥You'll NEVER Believe what Trump wants NOW!!
97.5K229 -
54:56
Digital Social Hour
1 day ago $9.79 earnedDOGE, Deep State, Drones & Charlie Kirk | Donald Trump Jr.
53.3K5 -
DVR
The Trish Regan Show
11 hours agoTrump‘s FCC Targets Disney CEO Bob Iger Over ABC News Alleged Misconduct
58.9K36 -
1:48:19
The Quartering
12 hours agoElon Calls White People Dumb, Vivek Calls American's Lazy & Why Modern Christmas Movies Suck!
141K112 -
2:08:42
The Dilley Show
13 hours ago $35.84 earnedH1B Visa Debate, Culture and More! w/Author Brenden Dilley 12/26/2024
122K40 -
4:55:59
LumpyPotatoX2
15 hours agoThirsty Thursday on BOX Day - #RumbleGaming
112K6 -
1:04:52
Geeks + Gamers
14 hours agoDisney RATIO'D on Christmas Day | Mufasa Embarrassed By Sonic 3
83.1K11 -
8:27:46
Sm0k3m
18 hours agoRumblers Assemble
52.7K2 -
10:37
Russell Brand
2 days agoHow is this even allowed?
207K921