arshajii
arshajii

Reputation: 129477

Java class diagram composition / aggregation for arrays

Consider the following:

class A {}

class B {
    private A[] a;
}

How would I represent the relationship between A and B on a class diagram? I would use composition / aggregation if B only held a single A (as opposed to an array), but in this case I'm not sure what should be done. Your help would be much appreciated!

Upvotes: 1

Views: 1303

Answers (1)

Rohit Jain
Rohit Jain

Reputation: 213193

Changing a single reference to an array doesn't change the meaning of composition..

It is still a composition..

By composition you mean some class A, is composed of a single instance of another class B (One-to-One Mapping), or a list of instances (One-to-Many Mapping)

Upvotes: 3

Related Questions