Thursday 2 June 2016

Benefit of having non final class

Imagine you find a problem with a method in a class you're using, but you don't have the source code.

So you can't modify the source to improve the method, but you can extend the class and override the method in your new subclass, and substitute the subclass everywhere the original super class is expected.

If the class is final, though, then you're stuck.


No comments:

Post a Comment

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If you are looking for a reference book on java then we recommend you to go for → Java The Complete Reference
Click on the image link below to get it now.