38 lines
812 B
Markdown
38 lines
812 B
Markdown
|
---
|
||
|
parents:
|
||
|
- "[[Вопросы для собеседование Java]]"
|
||
|
---
|
||
|
```java
|
||
|
public class Train {
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
test();
|
||
|
System.out.println("finish");
|
||
|
}
|
||
|
|
||
|
private static void test() {
|
||
|
try {
|
||
|
method();
|
||
|
} catch (RuntimeException runtimeException) {
|
||
|
System.out.println("catch runtime");
|
||
|
throw new Exception("mega surprise");
|
||
|
} catch (Exception exception) {
|
||
|
System.out.println("catch exception");
|
||
|
} finally {
|
||
|
System.out.println("finally");
|
||
|
}
|
||
|
System.out.println("message");
|
||
|
}
|
||
|
|
||
|
private static void method() {
|
||
|
throw new RuntimeException("surprise");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
```
|
||
|
|
||
|
%%
|
||
|
catch runtime
|
||
|
finally
|
||
|
mega surprise в стектрейсе
|
||
|
%%
|