Question

If I have 2 java classes, one class's method contains method variable that is a reference to the second class (not instance variable). How do I link these classes in UML diagram? I am giving an example for better clearance of question:

class A{
     methodA(B b){
      <do something>
} 
}

class B{

}
Was it helpful?

Solution

It's a dependency, kind of weak relationship. In this case it is establish only while the method execution and is typically merely indicated with a generic dependency:

enter image description here

Stronger kinds of relationships, like association or composition usually suggest member variables.

OTHER TIPS

If any class contains the reference of any other class (other than instance variable) then this relationship is know as composition Relationship. It can be depicted in UML using a class relationship. The black diamond represents composition in UML class diagram. The arrowhead on the other end of the relationship denotes that the relationship is navigable in only one direction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top