~/ learn/ comp-308/ cards/ Error Handling with Exceptions
1 of 24

Throw an exception when a guard fails

Throw an exception when a guard fails

Answer

if (level < 0) { throw new IllegalArgumentException("level must be >= 0"); }

`throw` launches the exception object; the method stops immediately and the stack unwinds to the nearest matching handler.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/f18ed4fa-9592-4f37-9968-d0069ddd3033/flashcard utf-8 LF