I the following two classes:
class a {
void foo(){
b object= new b();
object.baar();
}
}
class b {
void baar(){
}
}
How to express class a
using class b
with Class Diagram (which arrow to use)?
Whenever one class has a reference/uses another, it is said to have a dependency on it. In your example, class a
uses class b
. Therefore class a
has a dependency on class b
. For that, you can use the UML dashed line with open arrow as described here.
This is a very general relationship.
One class depends on another if the independent class is a parameter variable or local variable of a method of the dependent class.
If your class a
had an instance variable, you would use the association link instead.