0% found this document useful (0 votes)
1 views

Writing Your First Java Program

This document provides a step-by-step guide to writing your first Java program. It covers creating a new project, writing the code for a simple 'Hello, World!' program, understanding the code structure, and instructions for compiling and running the program. Additionally, it includes a task to modify the output message to print the user's name.

Uploaded by

dolatkumar913
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Writing Your First Java Program

This document provides a step-by-step guide to writing your first Java program. It covers creating a new project, writing the code for a simple 'Hello, World!' program, understanding the code structure, and instructions for compiling and running the program. Additionally, it includes a task to modify the output message to print the user's name.

Uploaded by

dolatkumar913
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

You might also like