☕ Java

What is Java?

Lesson 1 of 5 ~5 min

Java is a compiled, object-oriented, platform-independent programming language created by James Gosling at Sun Microsystems in 1995. It was designed to be simple, robust, and portable across platforms — following the famous philosophy of "Write once, run anywhere."

Java source code is compiled into bytecode, which runs on the Java Virtual Machine (JVM). This means the same Java program can run on Windows, macOS, Linux, or any system with a JVM installed — without recompilation.

Why Java?

Your first Java program

Every Java program starts with a class and a main method. Here's the classic "Hello, World!" example:

Editor
Java
Output

Try it

Edit the strings inside System.out.println() on the left. The output on the right updates as you type.

Anatomy of a Java program

A Java program is organized into classes. Every class can contain methods (functions), and the program's entry point is always public static void main(String[] args). Let's break down what each part means.

public class Main {
    // Every Java program needs a class
    // The class name must match the filename

    public static void main(String[] args) {
        // This is the entry point of the program
        // Java starts executing from here

        String name = "Alice";
        int age = 25;
        boolean isStudent = true;

        System.out.println("Name: " + name);
        System.out.println("Age: " + age);
        System.out.println("Student: " + isStudent);
    }
}

Key concepts

Java's role in the real world

Java is everywhere. It powers large enterprise backend systems at banks and insurance companies. It's the primary language for native Android development. Big data frameworks like Hadoop and Spark are written in Java. Microservices built with Spring Boot are a staple of modern cloud architectures. Learning Java opens doors to a vast professional landscape.

// Java's write-once-run-anywhere model:
// 1. You write .java source code
// 2. The compiler (javac) produces .class bytecode
// 3. The JVM executes the bytecode on any platform

// This means the SAME compiled code runs on:
// - Windows
// - macOS
// - Linux
// - Any device with a JVM

Quiz

What does JVM stand for?
Challenge

Write a Java program that prints your name, your favorite programming language, and the year you started coding. Use three separate System.out.println() calls.