Unique exception
public class MyException extends Exception {
...
}
try If an exception occurs in the try block, the processing is interrupted and the catch block is processed.
try
...
void method(){
try{
...
} catch (MyException1 | MyException2 e){
...
} catch (MyException3 e){
...
} finaly {
...
}
}
# throws, throw
Use throws when a method may pass an exception to the caller.
Also, use throw when explicitly throwing an exception. l
#### **`throws`**
```java
class classA {
void methodA() throes MyExceptionA {
...
if(isError){
throw new MyException();
}
...
}
}
Recommended Posts