简体   繁体   English

数组的Java类图组合/聚合

[英]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? 我如何在类图上表示AB之间的关系? 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. 如果B只持有单个A (而不是数组),我会使用组合/聚合,但在这种情况下,我不确定应该做什么。 Your help would be much appreciated! 非常感谢您的帮助!

Changing a single reference to an array doesn't change the meaning of composition.. 将单个引用更改为数组不会改变组合的含义。

It is still a composition .. 它仍然是一个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) 通过composition您的意思是某个类A,由另一个类B(一对一映射)的单个实例或实例列表(一对多映射)组成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM