Search code examples
javainheritanceumlextendsclass-diagram

How to use «extend» in a Java program?


In UML, class A extends class B, I don't know if it's true but it's a dependency relationship, not inheritance.

It says A «extend» B. I tried inheritance relationship but it didn't feel right.

How to use it in code?

enter image description here


Solution

  • There seems to be a confusion on UML elements here:

    • In UML there is indeed an «extend» dependency relationship, but it is specific to use-cases. It has nothing to do with the java extend.

    • In Java there is indeed an extend statement to specify inheritance. This is what UML calls generalization/specialization (hollow triangle arrow head/ plain line).

    You therefore need to correct your diagram, using inheritance instead of dependency.