Why is java.net.URL final?
<p>I would like to inherit from <a href="http://docs.oracle.com/javase/6/docs/api/java/net/URL.html#URL%28java.lang.String,%20java.lang.String,%20int,%20java.lang.String%29" rel="nofollow">java.net.URL</a> but I can not because it is final. I get the error:</p>

<pre><code>cannot inherit from final java.net.URL
</code></pre>

<p>Why is it final?</p>

<p>Some answers for the questions why <a href="http://stackoverflow.com/questions/2068804/why-is-string-final-in-java">String is final</a> state, that the JVM relies on String because it is a very basic data type. I can not see how this would apply to the URL type.</p>

<p><strong>Update</strong></p>

<p>Many answers and comments are giving reasons, why it is good practice to avoid inheritance. Some even think that everything should be final. But the reality is something different. Most classes in the JDK are <em>not</em> final. Being good practice is a reason why one <strong>should</strong> not inherit from java.net.URL. This might even apply to any class of the JDK. But when something is defined as final one <strong>can</strong> not inherit. This applies only to some very few classes as String or URL.</p>

<p>So there must be something different between URL and all the other non final classes. The question is: what is this difference, that makes it necessary, that URL is final?</p>

<p>Stating that I should not care about this question, because I should not inherit anyway is no answer to the question.</p>
