I am a beginner in programming. This time, I will output about ** exception handling ** as it is a continuation of the previous ** exception ** article.
** Processing after ** an exception was thrown at run time. (If exception handling is not performed, the system will be interrupted, but if exception handling is performed, the necessary processing can be executed before the interruption.) (Example) ・ Displays "An unexpected error has occurred". -Process to close the file etc ...
Write with ** [try → catch → finally] syntax **.
qiita.java
try {
//What you want to do (an exception may be thrown)
} catch() {
//Catch when an exception is thrown
} finally {
//You can write a process that is always performed regardless of whether an exception occurs and is caught.
}
Yes. You don't have to write it separately, just [try → catch]. However, I'm a beginner, so I don't know yet, but I saw an article somewhere that the moment when finally feels very grateful will come someday, so I don't have to write it, but it seems to be important.
[References] https://eng-entrance.com/java-finally
** * If you have any mistakes, I'm sorry, but I would appreciate it if you could let me know in the comments. ** **
Recommended Posts