inherit String class

String class can never be a base class, as it is declared final. Due to some optimizations taking place while creating a String object, which Developers of Java do not want Application developers to inherit from String class or override its methods. Hence String class is declared as final.

Click here for detailed description of final class

Also note that all wrapper classes like java.lang.Integer, java.lang.Float, java.lang.Short, etc… are final as well. Hence they cannot be base classes.

2 thoughts on “inherit String class”

Leave a Reply