deriving a class

Hi,

How do you derive a class from another class ? I thought to do something simple like:

class TestBufferextends StringBuffer

{

}

But I get error:The type TestBuffer cannot subclass the final class StringBuffer. What do I do wrong here ?

[402 byte] By [wmestdagha] at [2007-10-2 20:35:09]
# 1

>What do I

> do wrong here ?

Exactly what it says: You tried to extend a final class. Not all classes are meant to be extended. StringBuffer is one that is not, and so was marked as such with the final keyword in its declaration. You'll notice it's final if you look at its Javadocs.

http://java.sun.com/docs/books/tutorial/java/javaOO/final.html

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html

jverda at 2007-7-13 23:18:21 > top of Java-index,Java Essentials,New To Java...
# 2
Hi,Thank you for your reply. Strange making a class final. This prevent a programmer to make his derived class with a changed behaviour. That's what OOP is all about :(
wmestdagha at 2007-7-13 23:18:21 > top of Java-index,Java Essentials,New To Java...
# 3
Just because inheritance is part of OO, that doesn't mean that every class should be extended.
jverda at 2007-7-13 23:18:21 > top of Java-index,Java Essentials,New To Java...
# 4
Hi,No of course not. Thank you.
wmestdagha at 2007-7-13 23:18:21 > top of Java-index,Java Essentials,New To Java...