Glossary
138 terms from Java Beyond the Basics, in plain words, each with the chapter that teaches it.
#
- @BeforeEach
- A JUnit annotation for a method that runs before every test, used to give each test fresh objects such as a new StockLevel.
- @Test
- The JUnit annotation marking a method (no parameters, no return value) as a test to run.
A
- Absolute path, relative path
- An absolute path starts from the top of the disk, such as /home/jo/products.csv. A relative path, such as products.csv, is found from the working directory, the folder where you ran java.
- Abstract class
- A class marked abstract that can't be created with new and may leave some methods without a body for subclasses to fill in. Use it when subclasses share fields and code.
- Abstract method
- A method with no body, such as apply in Discount, which every implementing class or record must write.
- Arrange, act, assert
- The three steps of a typical test: set up the data, call the code, then check the result.
- ArrayDeque
- A collection that works from both ends, so it can be a queue (offer, poll, peek) or a stack (push, pop). Deque is short for double-ended queue, said like "deck".
- assertAll
- A JUnit method that runs several checks together and reports every one that fails, instead of stopping at the first.
- assertEquals
- A JUnit check that fails the test, showing both values, if the expected value and the actual value differ. Put the expected value first.
- assertThrows
- A JUnit check that some code, passed as a lambda, throws a given kind of exception. It fails if nothing or a different exception is thrown.
- AtomicInteger
- An integer whose updates, such as incrementAndGet(), can't be interrupted by other threads, which prevents lost counts in a race condition.
- AutoCloseable
- Anything with a close() method, so that try-with-resources can close it automatically when the block ends.
B
- Bounded type
- A type parameter limited to types that have what you need, such as <T extends Comparable<T>>, so maxOf can call compareTo.
- Build tool
- A program such as Maven or Gradle that compiles your code, downloads libraries, runs tests and packages the result from one command.
C
- Callable
- A task you hand to an executor: a Callable is a lambda that returns a value, and a Runnable is one that returns nothing.
- Cause
- The original exception passed along when you catch one and throw another, as in new IllegalArgumentException("bad line 4", e). The stack trace shows it under Caused by:.
- ChronoUnit
- A unit of time whose between(a, b) counts how many of that unit lie between two dates.
- Class literal
- Name.class, such as IllegalArgumentException.class: an object that stands for the class itself, used by assertThrows.
- ClassCastException
- A run-time error when a value is cast to the wrong type, for example (String) on something that isn't a String. Generics catch this mistake at compile time instead.
- Classpath
- The list of places where java looks for compiled classes, given with -cp, such as -cp target/classes.
- Collection
- The parent interface of List, Set and Queue. Map is separate and holds key-value pairs.
- Collector
- A recipe passed to collect() that says how to gather a stream's results, such as groupingBy to sort sales into a map by café, or partitioningBy to split them by a yes-or-no test.
- Command-line arguments
- Words typed after the program's name, which arrive in main's args array as text. Use Integer.parseInt to turn a word into a number.
- Compact constructor
- A record constructor written without a parameter list, whose checks run on every new record, like Product rejecting negative stock.
- Comparable
- An interface giving a type its natural order through compareTo, which returns negative, zero or positive. Strings and numbers implement it.
- Comparator
- A functional interface whose compare(a, b) orders two values from outside the type, so you can have many sort orders. Comparator.comparing(Product::name) builds one from a field.
- CompletableFuture
- A Java class that chains steps to run automatically when a result becomes available, so code can react to a slow task without blocking while it waits.
- Concurrency
- Having several threads of work in progress at once, which pays off when a program mostly waits for files, databases or other computers.
- ConcurrentHashMap
- A HashMap that many threads can update safely; its merge method does a safe update in one step.
- ConcurrentModificationException
- The exception thrown when you remove from a list inside a for-each loop, because the loop notices the list changed. Use an Iterator or removeIf instead.
- Coordinates
- The three values that identify a library on Maven Central: groupId (the organization), artifactId (the project) and version.
- CSV
- A plain text file format where each line is a row and values are separated by commas, like Jo's products.csv.
- Custom exception
- Your own exception class, such as OutOfStockException, that names a problem in your program's own words. Extend RuntimeException to make it unchecked.
D
- DateTimeFormatter
- A class that turns dates into text using a pattern such as EEE, MMM d, yyyy, so customers see Fri, Oct 23, 2026.
- Default method
- An interface method with a body, marked default, that every implementing type gets and may override, like roundUpToCase in ReorderPolicy.
- Dependency
- A library your project uses, named by its coordinates in pom.xml or build.gradle.kts, such as JUnit.
- Diamond operator
- The empty angle brackets in new Counter<>() that tell Java to copy the type arguments from the left side.
- Duration
- An amount of time, such as the PT1H24M30S between two instants. Period gives an amount in years, months and days.
E
- Effectively final
- A local variable that never changes after it is set. Lambdas may only use local variables that are effectively final.
- Enum
- A type with a fixed list of values, each an enum constant such as Category.MUG, so a typo like "Cofee" can't slip through.
- Environment variable
- A system setting, such as the Path variable listing the folders Windows searches for commands. Maven's bin folder must be on it.
- equals and hashCode
- Methods inherited from Object that say whether two objects are equal and give a number that hash collections use to find candidates. Override both with the same fields; records write them for you.
- ExecutionException
- What Future.get() throws when the task threw; getCause() holds the original exception.
- Executor
- An object that runs tasks on threads for you, such as one from Executors.newVirtualThreadPerTaskExecutor() that starts a virtual thread per task.
- Exhaustive
- A switch that covers every possible case (every enum constant or every permitted sealed type), so it needs no default and stops compiling if a case is added.
- Exit code
- The number a program returns when it ends: 0 means success and anything else means trouble. Scripts read it, and System.exit(2) sets it.
F
- Fat JAR
- A JAR with a program's dependencies packed inside, needed when the program uses libraries at run time. The maven-shade-plugin builds one.
- FIFO
- First in, first out: items leave a queue in the order they arrived, like Alex packing orders as they come.
- Files
- A class with static methods that read and write files, such as readAllLines, readString, write and lines. Most throw IOException.
- flatMap, reduce
- flatMap turns each element into a stream and joins them all into one stream; reduce(start, operation) combines all elements into one value.
- Format specifiers
- Codes inside text passed to formatted() that insert values: %d for a whole number, %.2f for a decimal with 2 places, %s for text, with widths like %-7s to pad columns and a comma to group thousands.
- Functional interface
- An interface with exactly one abstract method, so a lambda can stand in for it, like PriceRule.
- Future
- A promise of a result that is not ready yet, returned by submit; its get() waits until the result is available.
G
- Generic class
- A class, record or method written once with a type parameter (a placeholder such as T) so it works for many types, like Counter<T>. Generics catch wrong types at compile time.
- Gradle
- A Java build tool that uses the same layout and coordinates as Maven but describes the project in Kotlin code in build.gradle.kts.
H
- Homebrew
- The macOS package manager, used here with brew install maven.
- HTTP and JSON
- HTTP is the protocol programs use to talk to web services, and Java's `HttpClient` can call them. JSON is the text format those services usually use to exchange data.
I
- I/O
- Input and output: reading and writing data outside your program, such as files.
- Immutable
- Can't be changed once created, like records, strings and dates; methods such as plusDays return a new object.
- Inheritance
- Sharing code: a subclass extends a superclass and gets its fields and methods, like Coffee extending Product. A class extends only one class.
- instanceof
- Tests an object's type, and in p instanceof Cash cash also gives you the object as that type.
- Instant
- A moment in UTC with no time zone. Use instants in logs and convert to a zone only to show a person.
- Interface
- A list of methods that classes and records promise to provide, like Discount, without saying how they work. A type may implement many interfaces.
- InterruptedException
- A checked exception thrown when a waiting thread, such as one in Thread.sleep, is asked to stop early.
- IOException
- The checked exception for failed file and network I/O, which the compiler makes you handle. NoSuchFileException is the kind thrown for a missing file, so catch it first.
- ISO 8601
- The international standard for writing dates as yyyy-mm-dd, which LocalDate.parse expects.
- Iterator
- An object that walks a collection one item at a time with hasNext and next, and can safely remove the item it just returned.
J
- JAR
- A zip file of compiled .class files plus a manifest text file that describes it. Its Main-Class line names the class holding main, so java -jar can run it.
- java.base
- The JDK module that holds the core packages (java.lang, java.util, java.io, java.time) and is always available. Others include java.net.http for HTTP and java.sql for databases.
- java.time
- The package holding Java's modern date and time classes, preferred over the older Date and Calendar.
- jlink
- A JDK tool that builds a trimmed Java runtime holding only the modules your program needs, so users don't need the full JDK.
- jpackage
- A JDK tool that wraps your JAR and a runtime into an installer (.msi, .pkg, .deb) or, with --type app-image, a ready-to-run folder.
- JUnit
- Java's standard testing library, whose API is called Jupiter. It runs every @Test method.
L
- Lambda
- A method with no name, written where you need it, like cents -> cents - cents / 10. It implements a functional interface and can be stored or passed around.
- Lazy
- A stream is lazy: nothing happens until the terminal operation runs.
- Lifecycle
- Maven's ordered phases (compile, test, package, install); running a phase runs every phase before it.
- LIFO
- Last in, first out: the most recent item leaves first, like a stack used for an undo list.
- LinkedHashSet
- A set or map that keeps items in the order they were first added; a LinkedHashSet also drops duplicates.
- Local repository
- The .m2 folder in your home directory where Maven keeps downloaded plugins and dependencies, so later builds are fast.
- LocalDate
- A date with no time or zone, such as a roast date. LocalTime is a time of day, and LocalDateTime is a date plus a time, still with no zone.
- Locale
- A setting for language and region; Locale.US fixes the language of date names so output matches everywhere.
- Logging
- Recording what a program did, at levels such as INFO and ERROR, so problems can be traced later. In Java it is done with `System.Logger` or with libraries such as SLF4J.
M
- Maven
- The most widely used Java build tool. Its pom.xml (Project Object Model) describes the project's coordinates, Java version and dependencies in XML.
- Maven Central
- The public place where Java libraries are published, found at central.sonatype.com.
- Maven standard layout
- The folders every Maven project uses: code in src/main/java, tests in src/test/java, files the program reads in src/main/resources, and build output in target/, which you never edit.
- merge, computeIfAbsent
- Map and list methods that take lambdas and replace common loops: merge(key, 1, Integer::sum) counts, computeIfAbsent groups into lists, removeIf safely removes items, and replaceAll transforms every item.
- Method reference
- A short form of a lambda, such as Product::name for p -> p.name(), or TreeMap::new for a constructor.
- Mockito
- A Java library that creates stand-in (mock) objects for tests. It lets a test replace a real dependency with a controllable fake.
- Module
- A named group of packages. A module-info.java file says which other modules it requires and which of its packages it exports for others to use.
- Module import
- import module java.base; imports every package the module exports in one line, in place of many import lines (Java 25+).
- Multi-catch
- One catch block for several exception types, written catch (A | B e).
N
- Nested and anonymous classes
- A nested class is declared inside another class, and an anonymous class is declared with no name at the point where it is used. Older code often used anonymous classes for the short behaviors that lambdas now express.
- NullPointerException
- The error you get when you use null as if it were an object, which returning null for "not found" invites.
- Number
- The parent class of Integer and Double, whose doubleValue() gives any number as a double.
O
- Object
- The class every Java class extends automatically, which supplies toString, equals and hashCode.
- Optional
- A box that holds one value or nothing, returned instead of null so every caller knows to check first. Unwrap it with orElse, orElseThrow and similar methods.
- Overriding
- Overriding gives an inherited method a new body with the same name and parameters; overloading is the same name with different parameters. @Override makes the compiler check the match.
P
- Package
- A named group of classes whose folders match the name, such as com.kettleandcrane.quote. Package-private members have no modifier and are visible only inside the package.
- Parameterized test
- One test method run once per row of data; with @CsvSource each string is a row matched to the parameters, and each row counts as a separate test.
- Path
- A Path names a file or folder, such as Path.of("products.csv"). Relative paths are found from the working directory, the folder where you ran java.
- Pattern matching
- A type pattern (case Card c) tests an object's type and gives it to you as that type; a record pattern (case GiftCard(String code, int cents)) also takes the record apart into its fields.
- Platform thread
- A platform thread belongs to the operating system and is costly, so you get only a few thousand. A virtual thread is a light thread managed by Java (Java 21+), suited to waiting work, and you can start millions.
- Plugin
- A part of Maven or Gradle that does one job, such as maven-jar-plugin making a JAR.
- Policy
- A swappable reorder rule behind the ReorderPolicy interface, such as level or cover. Swapping behavior this way is the strategy design pattern.
- Polymorphism
- Using one type to stand for many: a List<Discount> holds PercentOff and AmountOff, and each runs its own version of apply.
- Predicate, Function, Consumer, Supplier
- Ready-made functional interfaces for lambdas: Predicate tests a value, Function converts one, Consumer uses one up, Supplier makes one, BiFunction takes two inputs, and UnaryOperator is a Function with the same input and output type.
- PriorityQueue
- A queue whose poll() always hands out the smallest item first.
Q
- Queue
- A queue is first in, first out (FIFO) and a stack is last in, first out (LIFO). ArrayDeque can act as either: offer, peek and poll for a queue; push and pop for a stack.
R
- Race condition
- A bug where the result depends on the timing of threads, such as two threads both reading 500 and both writing 501, so the counter loses an update.
- Record
- A small class that holds data and automatically gets equals, hashCode and toString. Records are immutable and can't extend a class.
- RuntimeException
- The parent class of unchecked exceptions such as IllegalArgumentException, which you needn't declare. Extend Exception instead for a checked one the compiler makes you handle.
S
- Sealed
- A sealed type lists with permits every type allowed to implement it, so a switch over it can be checked for completeness without a default.
- Semantic versioning
- A version-number scheme like 2.4.1: raise PATCH for fixes, MINOR for features and MAJOR for breaking changes.
- Sequenced collection
- A collection with a defined order (Java 21+), such as lists, ArrayDeque and LinkedHashSet, offering getFirst, getLast, addFirst and reversed. reversed() is a view, not a copy.
- Spring Boot
- A Java framework for building web applications and APIs, the subject of the next book; it works with Maven or Gradle and builds fat JARs for you.
- Stack trace
- The report Java prints when a program stops with an exception, listing where it happened. With a cause, it shows both exceptions, the second under Caused by:.
- Static import
- Importing a static method itself so you can write assertEquals(...) instead of Assertions.assertEquals(...).
- Stream
- A pipeline made of a source, zero or more intermediate operations (filter, map, sorted) and one terminal operation (sum, toList), which runs lazily and can be used only once.
- StringBuilder
- Text you can change: append adds to the end and returns the builder. String.join glues a list of strings with a separator.
- super
- A keyword for the superclass: super(name, priceCents) calls its constructor, and super.label() calls its version of a method.
- Switch expression
- A switch that produces a value, written with arrows (case NEW -> "...") so no break is needed. It can also match types and may throw in a case.
- synchronized
- A keyword on a method so only one thread at a time can run it, preventing race conditions.
T
- Test-driven development
- Writing a failing test first, watching it fail, then writing just enough code to pass. At least do it for bug fixes.
- Text block
- Multi-line text written between """ lines as it should look, with indentation up to the closing """ removed.
- Thread
- One path of work through a program; main runs on one. Thread.sleep pauses a thread to fake waiting.
- Toolchain
- Gradle's setting for which Java version builds the project.
- TreeMap
- A map that keeps its keys sorted, so floorKey(30) finds the largest key at or below 30, handy for ranges such as shipping weight bands.
- Try-with-resources
- try (resource) { ... } closes the resource when the block ends, even after an exception. It works with any AutoCloseable, such as files and executors.
- Type inference
- Java working out a type from the code, as with var or the diamond in new Pair<>(...), or a generic method's T from its argument.
U
- Unit test
- A small method that calls your code with known inputs and checks the answer automatically on every build. A failure means a wrong result; an error means an unexpected exception.
- Unmodifiable collections
- Lists and maps from List.of, Map.of, List.copyOf and a stream's toList() can't be changed; adding or removing throws UnsupportedOperationException. Copy into an ArrayList to change them.
- UTC
- Coordinated Universal Time, the world's reference clock, with no daylight saving.
- UTF-8
- The standard way to store text, including letters like é, as bytes. Files.readAllLines and readString read text this way.
V
- values, valueOf, ordinal
- Enum methods: values() lists all constants in order, valueOf turns exact text into a constant (or throws), ordinal() gives its position from 0, and name() gives its name as a string.
W
X
- XML
- A text format where each value sits between <tag> and </tag>. Maven's pom.xml is written in it.
Z
- ZonedDateTime
- A date and time in a named time zone, such as America/Los_Angeles; withZoneSameInstant shows the same moment in another zone.