Learn to manually throw exceptions and declare exceptions that a method might throw.
While `try-catch` is used to handle exceptions, the `throw` and `throws` keywords are used to generate and propagate them. The `throw` keyword is used to manually throw a specific exception from your code. You can throw any instance of a class that extends `Throwable`. This is useful when you encounter an error condition in your own logic that the standard Java libraries wouldn't know about. For example, if a method receives an invalid argument (e.g., a negative age), you can `throw new IllegalArgumentException("Age cannot be negative");`. This creates a new exception object and throws it, immediately stopping the current method's execution and passing the exception up the call stack. The `throws` keyword, on the other hand, is used in a method's signature. It declares the types of checked exceptions that the method might throw but does not handle itself. This acts as a warning to any other method that calls it. The calling method is then responsible for either handling the declared exception with a `try-catch` block or propagating it further up the call stack by declaring it with its own `throws` clause. This mechanism enforces a 'catch or declare' policy for checked exceptions, ensuring that they are consciously dealt with by the programmer. For example, a method that reads from a file might be declared as `public void readFile() throws IOException;`, signaling that callers must handle potential I/O errors.