Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 328
gorkemoji Avatar asked Mar 30 '26 03:03

gorkemoji


1 Answers

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.

like image 117
Christophe Avatar answered Apr 01 '26 08:04

Christophe