Thursday, November 6, 2008


class Foo extends String
// This avoids a warning
private static final long serialVersionUID = 1L;

$ javac -Xlint:all cannot inherit from final java.lang.String
class Foo extends String
1 error

I know what final classes are. I think they're the wrong solution to any problem, but I know what they are.

But what is the argument for making String a final class? And if the reason is "because String is special and the compiler knows about it and blah blah", it shouldn't be.