On this page
  1. RuntimeException
  2. Availability
  3. Syntax & Overview
  4. Notes & Pitfalls
  5. Example

RuntimeException

Prev: `AutoCloseable` | Up: builtins | Next: `primitives`
Rel: builtins, Classes, Records & Sealed Hierarchies
Ref: Java Docs — RuntimeException
Tags: #public #prog #java #builtins #tier/core


Availability

Built-in / java.lang (java.lang Exception Base) — available with zero import statements.

Syntax & Overview

public class AppException extends RuntimeException

Base class for unchecked exceptions (not required in throws clauses), distinct from checked Exception subclasses.

Notes & Pitfalls

Example

static int requirePositive(int n) {
    if (n <= 0) throw new IllegalArgumentException("must be > 0: " + n);
    return n;
}
assert requirePositive(5) == 5;

Linked from

Related notes