Oop

Java Basics

What Java this book assumes, and where to learn it. The Java guide is the single source of truth for the language: syntax, control flow, classes, collections, exceptions and generics. This page maps each topic to its Java guide lesson and lists what you should be able to read before the design chapters.

Suggest an edit

Java Basics — What This Book Assumes, and Where to Learn It

This book teaches design: how to split a system into classes, give each class a clear job, and connect them so that the system is easy to change. Its examples are written in Java, with Python versions alongside. It does not teach the Java language itself.

The Java language is taught in one place, the Java guide. Every Java rule this book relies on is explained there, once, with verified output, so the two books never disagree. This page tells you which parts of the Java guide you need, and in what order.

💡 The core idea.

  • The Java guide teaches the language; this book uses it. When a lesson here needs a Java rule, it links to the Java guide instead of repeating it.
  • To follow the design chapters, you need the Java guide's first three chapters, plus its lessons on collections, exceptions and interfaces.
  • The rest of this chapter covers what the language lessons don't: how to use the OOP ideas as design tools.

Table of contents

  1. What you need before the design chapters
  2. Where each topic lives in the Java guide
  3. How this chapter continues
  4. Check yourself

1. What you need before the design chapters

You are ready for the rest of this book if you can read the code below and predict what it prints. It uses a class, a constructor, a private field, a method, a list and a loop, which covers most of what the design examples need.

Output:

items total: 2499 cents

If any line of the Java version is unclear, the lessons in section 2 cover it.


2. Where each topic lives in the Java guide

Start here (needed for every chapter):

Topic Java guide lesson
What Java is, compiling and running a program What Java Is & Running Code
Variables, primitive types, type casting Variables & Primitive Types
Operators and arithmetic Numbers & Arithmetic
Strings Strings, the Basics
Reading input, printing output Input & Output
Booleans, if/switch, loops Booleans & Logic, Conditionals, Loops
Arrays Arrays
Methods, parameters, return values Methods
Classes, objects, fields, constructors Defining Classes & Creating Objects
private, public, getters and setters Encapsulation & Access Modifiers
static members static vs Instance
References, == vs equals, null References, Equality & the Object Model

Needed by the OOP, SOLID and design-pattern chapters:

Topic Java guide lesson
Lists, maps, sets The Collections Framework, Sets & Maps
equals and hashCode for objects in collections equals & hashCode
Generics Generics
Enums and records Enums & Records
Inheritance, overriding, super, polymorphism Inheritance & Polymorphism
Abstract classes and interfaces Abstract Classes & Interfaces
Exceptions: try/catch/finally, checked vs unchecked, custom exceptions Exceptions
Nested and anonymous classes, lambdas Nested & Anonymous Classes; Lambdas

Needed by the concurrency chapter: Concurrency: the Basics, Concurrency: Coordination and Concurrency: High-Level & Virtual Threads.

Python. Most examples in this book also have a Python version, placed next to the Java one. The Python versions use only the standard library and are written to be read without a separate Python course.


3. How this chapter continues

The next lessons use the object-oriented ideas as design tools, and link back to the Java guide for the language rules:

  1. Encapsulation, Inheritance & Polymorphism: protecting invariants, when inheritance is the wrong tool, and replacing type checks with polymorphism.
  2. Abstraction & Interfaces: programming to a contract, interface or abstract class, and the design cost of static.
  3. Errors, Generics & Resources in Design: exceptions as part of an API, generic components, and who owns a resource.
  4. Relationships and Object Behaviour: association, aggregation and composition, and copying objects.

✅ Check yourself

Answer these before moving on. If one is hard, follow its link in section 2.

Your Turn

Before you move on, check your understanding with the coach — explain the idea, apply it, weigh the trade-offs, then defend your reasoning.

Mark as readBook versionff97b7f