Free through lesson 3

Java for Beginners

From how the JVM works through types, control structures, arrays, methods, object orientation, exceptions, collections, lambdas and streams. Fifty lessons that take you to the point where you can assemble a to-do app that saves to a file entirely on your own. Every piece of code and result shown was produced by actually running OpenJDK 21.

about 3.5 hours in total (estimate)

Slides for this course (for classes and in-house training) →

Curriculum

The 50 lessons are grouped into seven chapters. Working through them in order is the best way, but you are welcome to dip into whatever interests you. Note: this cannot run inside the browser, so try it with your own JDK 21 using javac and java.

Chapter 1 — Getting started (lessons 1–6)

You get to grips with how Java runs, install the JDK, and get to the point of running it yourself. You go as far as variables, primitive types and type conversion.

Chapter 2 — Values and strings (lessons 7–12)

You cover operators, constants and String. You learn why you must not compare with ==, and how to read input from the keyboard.

Chapter 3 — Control structures (lessons 13–18)

You cover conditionals and repetition: the order of your else if branches, switch expressions, how to avoid infinite loops, and break and continue.

Chapter 4 — Arrays and methods (lessons 19–25)

You handle groups of values of the same type and split work up by giving it a name. You finish by assembling a complete grade-tallying program.

Chapter 5 — Classes and objects (lessons 26–33)

The doorway into object orientation. Blueprints and instances, this, constructors, encapsulation, static, packages, and on to inheritance.

Chapter 6 — Abstraction and exceptions (lessons 34–41)

You gather behavior with abstract classes and interfaces, and tidy your types with record and enum. Finally you cover how to throw and catch exceptions.

Chapter 7 — Collections and functional style (lessons 42–50)

List, Map and Set with generics, lambdas and streams, Optional, and file I/O. You finish by building a to-do app that saves to a file.

42

List and ArrayList

An array whose length can change. The convention of declaring it as the interface type, the autoboxing trap, and removing during a loop.

about 4 min 🔒 Basic
43

Map and HashMap

Looking up a value from a key in one step. A missing key is null, the order is not guaranteed, and the standard aggregation pattern.

about 3 min 🔒 Basic
44

Set, and choosing a collection

Set, which allows no duplicates, and set operations. The speed difference in contains, and three questions for choosing between List, Map and Set.

about 4 min 🔒 Basic
45

Generics

What a type parameter is actually doing. The danger of raw types, writing your own generic class, and upper bounds and type erasure.

about 4 min 🔒 Basic
46

Lambdas and functional interfaces

The notation for passing a piece of work itself as a value. The standard functional interfaces, method references, and Comparator.

about 6 min 🔒 Basic
47

The Stream API

Filter, transform and aggregate in one flow. groupingBy, and the properties of lazy evaluation and single use.

about 5 min 🔒 Basic
48

Optional and null safety

Expressing "there might be no value" in the type. Chaining orElse and map, and where it is appropriate to use.

about 4 min 🔒 Basic
49

File I/O

Reading and writing in a few lines with java.nio.file.Files. Treating a file as a list of lines, Files.lines, and what a relative path is relative to.

about 4 min 🔒 Basic
50

[Project] Wrapping up with a to-do app

Combining enums, records, custom exceptions, List, Stream, Optional and file I/O into one program.

about 4 min 🔒 Basic

Once you have finished all 50 lessons, build for the web in the same language with Spring Boot for Beginners, or start from how servlets work in JSP & Servlets for Beginners. Membership unlocks every course.