Java Aggregation (HAS-A relationship)

Posted morningdew

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java Aggregation (HAS-A relationship)相关的知识,希望对你有一定的参考价值。

Aggregation (HAS-A)

HAS-A relationship is based on usage, rather than inheritance. In other words, class A has-a relationship with class B, if code in class A has a reference to an instance of class B.

 

example

class Student
{
 String name;
 Address ad;
}

here we say that student has-a address

技术分享

 

 

 

 




以上是关于Java Aggregation (HAS-A relationship)的主要内容,如果未能解决你的问题,请参考以下文章

Java千百问_05面向对象(006)_is-a,has-a,like-a是什么

uml设计之类关系

NEST - How can i do multiple nested aggregation?

与 Collection 对象具有 has-a 关系的类是不是与 Collection 的元素有关系?

java中 is - a和 has - a的区别

Association, Composition and Aggregation in Java