组合关系(强拥有关系,生命周期相同,如鸟和翅膀)

public class TestOne {

}

public class TestTwo {
	private TestOne test1;
	public TestTwo() {
		// TODO Auto-generated constructor stub
		 test1 = new TestOne();
	}
}

 

 

聚合关系(弱拥有关系,如公司和员工,员工可以离开公司)

public class TestOne {

}

public class TestTwo {
	private TestOne test1;
}

简单理解,TestTwo类用到了TestOne类的实例。

相关文章:

  • 2022-12-23
  • 2021-05-17
  • 2021-09-22
  • 2022-12-23
  • 2022-02-13
猜你喜欢
  • 2021-12-19
  • 2022-03-09
  • 2022-01-12
  • 2021-10-04
  • 2022-12-23
  • 2021-11-18
  • 2021-08-14
相关资源
相似解决方案