百度地图聚合示例_Java中的聚合:定义和示例

百度地图聚合示例

Aggregation in Java is a relationship between two classes that is best described as a "has-a" and "whole/part" relationship. It is a more specialized version of the association relationship. The aggregate class contains a reference to another class and is said to have ownership of that class. Each class referenced is considered to be part-of the aggregate class.

Java中的聚合   是两个类之间的关系,最好将其描述为“具有”和“整体/部分”关系。 它是关联关系的更专业版本。 聚合类包含对另一个类的引用,并说拥有该类的所有权。 引用的每一个类被认为是部分的聚合类。

Ownership occurs because there can be no cyclic references in an aggregation relationship. If Class A contains a reference to Class B and Class B contains a reference to Class A then no clear ownership can be determined and the relationship is simply one of association.

发生所有权是因为聚合关系中不能存在循环引用。 如果A类包含对B类的引用,而B类包含对A类的引用,则无法确定明确的所有权,并且该关系只是关联之一。

For example, if you imagine that a Student class that stores information about individual students at a school. Now assume a Subject class that holds the details about a particular subject (e.g., history, geography). If the Student class is defined to contain a Subject object then it can be said that the Student object has-a Subject object. The Subject object also makes up part-of the Student object — after all, there is no student without a subject to study. The Student object, therefore, owns the Subject object.

例如,如果您想象一个学生类存储有关学校中各个学生的信息。 现在假定一个Subject类,其中包含有关特定主题的详细信息(例如,历史,地理)。 如果将Student类定义为包含Subject对象,则可以说Student对象具有 -Subject对象。 Subject对象也弥补了Student对象部分的 -毕竟,有没有受到研究没有学生。 因此,Student对象拥有Subject对象。

例子 ( Examples )

Define an aggregation relationship between Student class and the Subject class as follows:

定义学生类和主题类之间的聚合关系,如下所示:


 public class Subject {
private String name;
public void setName(String name)  {
this.name = name;
}
public String getName()
{
return name;
}
}
public class Student {
private Subject[] studyAreas = new Subject[10];
//the rest of the Stud

翻译自: https://www.thoughtco.com/aggregation-2033995

百度地图聚合示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值