If you read my previous post, you know that Day 1 was all about setting up my Java development environment. Now that everything is ready, it’s time to write some actual Java code! 🚀
To save myself some keystrokes (and give you a more visual guide), I’ll be using video clips from Caleb Curry’s Java tutorial—because, let’s be honest, watching something is sometimes way easier than reading long explanations! 😁
Creating a New Java Project in Eclipse
I followed the steps in this video clip to create a new Java project using Eclipse. Since the clip is from Caleb's original tutorial, I had to make a few small tweaks because Eclipse’s default project setup has changed slightly over time. But here’s a challenge for you—try figuring out the tweaks yourself! A little bit of problem-solving will add to your technical sophistication and serve you well on your programming journey. 😉
Creating the First Java Program
I followed the steps in this clip to create my very first Java program—smooth sailing, no hiccups! The process involves creating a Java class using the IDE. In Java, the class name must match the filename that contains it. So, in this case, I created a file named MySweetProgram.java
, which holds a class with the same name: MySweetProgram
.
In the next post, I'll give a brief and superficial introduction to classes. For now, just think of a class as a container that holds different pieces of your program.
Tweak and Run the First Java Program
After setting up the program following the clip above, I used this clip to tweak the code and finally run it—successfully printing the phrase "Hello there!" to the console. Btw,these are the lines of our first program:
public class MySweetProgram {
public static void main(String[] args) {
System.out.println("Hello there!");
}
}
👉 "In the next post, we’ll learn more about the nitty-gritty of the program we've just finished writing.
Top comments (0)