You are on page 1of 1

difference between final,finalize,finally keywords

----------------------------------------------------------------

1) final - refer a variable to the final(constant). we can't modify.


->It is a keyword
final method-we can't override
final class-we can't inheritance

2) finalize()-It is a method.
->It is similar to destructor function in C++.
->The garbarge collected object can be reclaimed using finalize() method.
->It is called by gc()method [gc-garbage collector].
protected void finalize()
{-----}

3) finally - keyword
->It is used in exception handling block.
->It is automatically work even if the corresponding catch block is matched or
not.
->It mainly used for closing connection,Streams.

You might also like