JavaBeginner#exceptions

What is the difference between throw and throws?

throw is a statement that actually raises an exception. throws is a method signature clause declaring that the method may propagate certain checked exceptions.

Example
void validate(int age) throws IllegalArgumentException {
  if (age < 0) throw new IllegalArgumentException("Negative age");
}

Related Questions

1
JavaIntermediate#exceptions

Explain try-with-resources.

Open
2
JavaIntermediate#fundamentals

What is autoboxing and unboxing?

Open
3
JavaIntermediate#collections

What is the difference between Comparable and Comparator?

Open