throw and throws in Java — a practical guide to Java throw throws with clear examples you can reuse in real projects.
Java Tutorial Series (48/90). Prefer one article? Read the complete Java tutorial.
Short description
`throw` creates/raises an exception. `throws` advertises checked exceptions a method may pass to callers.
throw/throws
static int parse(String s) throws NumberFormatException {
if (s == null) throw new IllegalArgumentException("null");
return Integer.parseInt(s);
}