Files
freeCodeCamp/guide/russian/java/finally-keyword/index.md
2018-10-16 21:32:40 +05:30

22 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Finally
localeTitle: в заключение
---
## в конце концов
Блок finally всегда выполняется, когда блок try завершается. Это гарантирует, что блок finally будет выполнен, даже если произойдет непредвиденное исключение. Но, наконец, полезно не только для обработки исключений - это позволяет программисту избежать случайного обхода кода очистки путем возврата, продолжения или разрыва. Включение кода очистки в блок finally всегда является хорошей практикой, даже если не ожидается никаких исключений.
**_Пример:_**
```java
try {
// Normal execution path
throw new EmptyStackException();
} catch (ExampleException ee) {
// deal with the ExampleException
} finally {
// This optional section is executed upon termination of any of the try or catch blocks above,
// except when System.exit() is called in "try" or "catch" blocks;
}
```