Chapter 1: Introduction to Java

Step 1: What is Java?

  • Java is a high-level, object-oriented programming language
  • Created by James Gosling at Sun Microsystems in 1995
  • Key Features:
    • Platform Independent (Write Once, Run Anywhere)
    • Object-Oriented
    • Secure and Robust
    • Multithreaded
    • High Performance

Step 2: Setting Up Your Environment

  1. Download the JDK (Java Development Kit) from the Oracle or OpenJDK website
  2. Install the JDK on your computer
  3. Set up environment variables (JAVA_HOME, PATH) if needed
  4. Install an IDE:
    • IntelliJ IDEA (Recommended)
    • Eclipse
    • VS Code with Java extensions

Step 3: Your First Java Program

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Step 4: How to Run

  1. Save file as HelloWorld.java
  2. Compile: javac HelloWorld.java
  3. Run: java HelloWorld

Step 5: Understanding the Structure

  1. public class HelloWorld → Class declaration
  2. main method → Entry point
  3. System.out.println → Output statement

Practice: Write a program that prints your name