Why Java?

Java compiles to bytecode, which runs on the JVM — the same .class file works on Linux, macOS and Windows. A new release ships every six months, an LTS release every two years.

Version Year Highlights
8 2014 lambdas, streams, Optional, java.time
11 LTS 2018 HTTP client
17 LTS 2021 records, sealed classes, text blocks, switch expressions
21 LTS 2023 virtual threads, pattern matching for switch
25 LTS 2025 compact source files & IO, module imports, scoped values

Where it is used

Backends (Spring Boot, Quarkus), Android, big data (Kafka, Spark, Elasticsearch), and most developer tooling.

Java ≠ JavaScript

Unrelated languages. The name was a 1995 marketing decision.

Three acronyms

  • JDK — compiler, JShell, tools (what you install)
  • JRE — JVM + standard library
  • JVM — runs bytecode, compiles hot code to machine code (JIT), collects garbage

You never free memory manually.

Static typing

Types are checked at compile time:

int age = 30;
age = "thirty";     // compile error

var infers the type — it does not make Java dynamic:

var age = 30;                        // int
var names = new ArrayList<String>(); // ArrayList<String>

Conventions

Element Style Example
classes, records, interfaces UpperCamelCase BankAccount
methods, variables lowerCamelCase computeTotal
constants UPPER_SNAKE_CASE MAX_SIZE
packages all lowercase com.example.shop
file name = public class name BankAccount.java

Four spaces of indentation, opening brace on the same line.

class Account {
    private final String owner;

    Account(String owner) {
        this.owner = owner;
    }
}

Comments

// line

/* block */

/**
 * Javadoc — rendered to HTML docs.
 * @param amount deposit in cents
 * @return the new balance
 */

What Java does not have

  • free functions (every method belongs to a type)
  • multiple class inheritance (interfaces instead)
  • pointer arithmetic or manual memory management
  • operator overloading (+ on strings is the one exception)

★ Exercises

  1. Which Java version is active on your machine? Is it an LTS?
  2. Rewrite in proper Java style: max retry count (constant), user profile (class), load data (method).
  3. Explain JDK vs JRE vs JVM in your own words.
  4. Why does var x; not compile? Try it in JShell and read the error.