freeCodeCamp/guide/arabic/java/finally-keyword/index.md

20 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Finally
localeTitle: أخيرا
---
## أخيرا
وينتهي الجزء الأخير دائمًا عند الخروج من المحاولة. هذا يضمن أن يتم تنفيذ كتلة النهاية حتى في حالة حدوث استثناء غير متوقع. ولكن في النهاية مفيد أكثر من مجرد معالجة الاستثناءات - فهو يسمح للمبرمج بتجنب إزالة رمز التنظيف دون قصد عن طريق العودة أو المتابعة أو الفشل. وضع كود التنظيف في نهاية المطاف هو دائما ممارسة جيدة ، حتى عندما لا يتوقع أي استثناءات.
**_مثال:_**
`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;
}
`