What could be a bad example of inheritance in Java?

I know the advantages of inheritance in Java, but it’s a little difficult for me to admit that it also has disadvantages. Can someone give me a bad example of inheritance in Java?

+5
source share
5 answers
  • Stack extends Vector. The stack is not a vector.
  • Properties extends Hashtable. The property table is not a hash table.

See this answer for a quote from Effective Java.

It was easy to write an implementation Stackusing what was already implemented in Vector(similar to Properties), but it created problems - see here

+7
source

(, ), , , . , API , API .

, , - . Java 5, enums , , .

Java :

. , , . , API-, .

+5

, Java, , . , ( Gang of Four " " ).

, , , . , , , . - , , , , , ..

+4

, , "is-a", , , , .

+1

- .

: " , ". : , , , , "" "", , , .

, , :

  • Java ( 16): ()
+1

All Articles