From your first class to a service-level middle

A trail through modern Java. First the class, the main method and types that do not lie. Then objects, collections and exceptions. At the end, generics and the shape of a small HTTP handler, the kind a middle developer meets every week.

Foundation

A class, a launch and a package: what a Java program is made of.

  1. The class and the entry point — Why a program is a class and not a free-standing script.
  2. Compiling and running — How javac differs from java, and where the .class file goes.
  3. Packages — Why package exists and why import is not copying code.

Types

Primitives, strings and wrappers: where the value is and where the reference is.

  1. Primitives — int, long, double, boolean, and why char is not a string.
  2. Strings — String is immutable, and == on it is almost always a mistake.
  3. Wrappers and null — Integer can be null, int cannot.

Control flow

Branches, loops and switch: the program chooses and repeats.

  1. Branches — if reads a boolean, not "something that looks like true".
  2. Loops — for, while, and where a loop has to end.
  3. Switch — The new switch is an expression; the old one falls through easily.

Objects

Fields, boundaries and short immutable types.

  1. Fields and the constructor — An object is assembled once, not patched from the outside.
  2. Encapsulation — The field is private, the behaviour is a method.
  3. Records — A short immutable data carrier.

Collections

Lists, maps and object equality.

  1. Lists — ArrayList keeps order and can grow.
  2. Maps — A key is found in constant time; order is not a promise.
  3. Equality — equals and hashCode live as a pair.

The service

Errors, generics and the shape of a response.

  1. Exceptions — A failure is an object, and you catch it narrowly.
  2. Generics — A list of strings is not a list of who knows what.
  3. The service response — The code and the short line the client will see.