First Steps
First Steps
Tier 0 of the Java book, for readers with zero programming background. Five chapters take you from "what is a program?" to a working interactive program — compiling and running code, values and the eight primitives, arithmetic and its traps, text, and input/output — with every example compiled and run, and every compiler error shown for real.
Suggest an editFirst Steps
This is Tier 0 — the beginning. It assumes you have never programmed before, in any language. By the end of these five chapters you will have written, compiled, and run real Java: doing arithmetic, building text, reading what a person types, and printing answers back. Along the way you'll meet the idea that runs through the whole book — that Java checks your program twice, once when the compiler reads it and again when the JVM runs it — and you'll learn to read both kinds of message.
Five chapters, in order:
- What Java Is & Running Code — what a program is, the compile-then-run loop (
javacand the JVM), whypublic static void mainlooks the way it does, andprintln— the command that lets a program talk back. - Variables & Primitive Types — naming values so you can reuse them, static typing, and the eight built-in kinds of value: whole numbers, decimals, true/false, and single characters.
- Numbers & Arithmetic — the operators, why integer division truncates, and why an
intcan silently wrap past its range to a negative number. - Strings, the Basics — building and reshaping text, why a String can never be changed, and the
==-vs-.equalstrap that comparing text is full of. - Input & Output — formatted output with
printf, reading typed input withScanner, turning text into numbers, and writing a first interactive program.
Every code block with a ▶ Run button is live — click it, change the code, run it again. The fastest way to learn at this tier is to perturb working examples: change a number, swap a word, break something on purpose, and see what the compiler or the JVM says. You cannot harm anything; the worst case is an error message, and reading error messages is itself a skill these chapters build.
📘 How to read the Intuition boxes. Each one is built in three moves:
- The mechanism — what the compiler and the JVM are actually doing.
- A concrete bite — a specific, runnable failure (often a real compiler error), shown so the trap is visible.
- The earned rule — the decision heuristic, now justified rather than asserted, plus its cost.