I would like to inherit from java.net.URL , but I can not, because it is final. I get an error message:
cannot inherit from final java.net.URL
Why is this final?
Some answers to questions about why String is final indicate that the JVM relies on String because it is a very simple data type. I don’t see how this applies to the type of URL.
Update
Many answers and comments provide reasons why it is good practice to avoid inheritance. Some even think that everything should be final. But reality is something else. Most classes in the JDK are not final. Being good practice is the reason why one should not inherit from java.net.URL. This can even apply to any JDK class. But when something is defined as final, it may not inherit. This only applies to some very few classes in the form of a String or URL.
So there must be something else between the URL and all the other fuzzy classes. The question is: what is the difference, what makes the URL final?
Stating that I should not care about this question because I should not inherit, this is not the answer to the question.
ceving
source share