typestar

Language basics

29 steps in 9 sets of Java.

Java turned thirty in 2025 and still runs more production code than almost anything else. The language of that code has quietly changed: var arrived in 10, switch grew arrows and then patterns, records collapsed the data class, and text blocks ended the escaped-string era. Modern Java in a single file carries far less ceremony than its reputation, and the JVM underneath remains one of the most heavily engineered runtimes ever built.

This tour covers the shared core in that modern form — variables, strings, control flow, collections, classes — then the pieces that shaped a generation of languages: interfaces with default methods, lambdas and method references, Optional, and the Streams API. The encore ships two complete programs with a classic main. Every seed compiles under javac 21 before it reaches you.

Start this tour

Variables & types

  • Variables & typesHow Java declares things: inferred with var, spelled out, or final.
  • Numbers & castsWidening is automatic, narrowing needs a cast, and longs wear an L.
  • MathThe static toolbox behind every calculation.

Strings

  • String methodsThe everyday string toolkit: trim, transform, search and slice.
  • Text blocksMulti-line strings that keep their shape.
  • Split & joinStrings to arrays and back again.
  • StringBuilderStrings are immutable, so repeated concatenation copies; a builder does not.

Flow control

  • If & elseBranching: the if/else chain and the conditional operator.
  • Switch expressionsThe modern switch returns a value and matches patterns, not just constants.
  • Loopsfor counts, for-each walks, while runs until told otherwise.

Collections

  • ArraysFixed-size and primitive-friendly, with a utility class for the rest.
  • ListsThe resizable workhorse collection.
  • MapsKey to value, with safe reads and one-line tallies.
  • SetsMembership in constant time, or sorted for free.

Methods & lambdas

  • Static methodsOverloading stands in for the default parameters Java never got.
  • LambdasFunctions as values, through one-method interfaces.
  • OptionalA container that admits it might be empty.

Classes & records

  • Classes & fieldsState made private, behavior made public.
  • InheritanceOne base contract, many behaviors, chosen at run time.
  • RecordsA whole value class in one line.
  • InterfacesThe contract, plus behavior the contract can ship itself.

Streams

Errors & files

  • Try & catchCatch the exception you expect; let the rest travel.
  • FilesWhole-file reads and writes in single calls.
  • try-with-resourcesDeterministic cleanup: whatever the try opened, it closes.

Encore

  • word_freq.javaThe word-count CLI in Java: read a file, tally a map, print a top ten.
  • grade_report.javaA gradebook in one file: averages, letter grades and a summary.

The other Java tours