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
- Download the JDK (Java Development Kit) from the Oracle or OpenJDK website
- Install the JDK on your computer
- Set up environment variables (JAVA_HOME, PATH) if needed
- 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
- Save file as HelloWorld.java
- Compile: javac HelloWorld.java
- Run: java HelloWorld
Step 5: Understanding the Structure
- public class HelloWorld → Class declaration
- main method → Entry point
- System.out.println → Output statement
Practice: Write a program that prints your name