Exception handling

Java program exceptions can be divided into two types: Erro and Exception:

Exception

Common exceptions:

Exception handling

There are two exception handling methods: try-catch-finally and throws exception

  • try-catch-finally:

  • throws

After executing exception code throws, subsequent code does not continue to execute

Manually creating an Exception

Throws a RuntimeException. Throws a try-catch Exception. Throws a RuntimeException

Custom exception classes

Custom Exception classes need to inherit from Exception or RuntimeException

Throw and throws