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?
Stack extends Vector
Properties extends Hashtable
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
Stack
Vector
Properties
(, ), , , . , API , API .
, , - . Java 5, enums , , .
Java :
. , , . , API-, .
, Java, , . , ( Gang of Four " " ).
, , , . , , , . - , , , , , ..
, , "is-a", , , , .
- .
: " , ". : , , , , "" "", , , .
, , :