throw
A statement that deliberately raises an exception object.
What does throw do in Java?
throw — A statement that deliberately raises an exception object.
class Reservation {
void reserve(int seats) {
if (seats < 1) {
throw new IllegalArgumentException("seats");
}
}
}
Level: Journeyman · More Java terms at this level
Updated