final/finalize()/finally keywords in Java

Final keyword can be used with class, method and variable. A final class can’t be instantiated, a final method can’t be overridden, and a final variable can’t be reassigned.
Finally keywords are used to create a block of code that follows a try block. A finally black of code always executes, where or not exception has occurred. Using a finally block allows you to run any clean-up type statements that you wish to execute. – try catch finally
finalize() method is used just before the object is destroyed and can be called just prior to object creation. In plain explanation, there is no destructor method in Java, but for programs in C or C++, we need a destructor to collect the garbage, so when a java call a non java code, we need to use finalize to collect garbage for us.

posted @ 2020-10-29 10:14  EvanMeetTheWorld  阅读(10)  评论(0)    收藏  举报