Writing Your First Java Program
## Step 1: Open Your IDE and Create a New Java Project
If you're using IntelliJ IDEA, Eclipse, or VS Code, follow these steps:
1. Open your IDE.
2. Create a new Java Project (or Java Class in VS Code).
3. Name it "FirstJavaProgram".
## Step 2: Write the Code
Create a new file "Main.java" and write this code:
// This is my first Java program
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
## Step 3: Understanding the Code
- public class Main - Defines a class named Main.
- public static void main(String[] args) - The main method, where execution starts.
- System.out.println("Hello, World!"); - Prints "Hello, World!" to the console.
## Step 4: Compile and Run
- Click Run (or type javac Main.java in the terminal, then java Main).
- You should see:
Hello, World!
## Task for You:
1. Run the program and confirm it prints "Hello, World!".
2. Modify the message to print your name instead.