public class Person { private Integer id; private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
public class DependencyAndRelation { private Dependency dependency; public void createRelation(Relation relation) { } public Study startStudy() { return null; } public void fav(){ Eat eat = new Eat(); } } class Dependency{} class Relation{} class Study{} class Eat{}
DependencyAndRelation
中分别通过属性方式使用到Dependency
;通过入参方式使用到Relation
;通过出参方式使用到Study
;通过局部变量的方式使用到了Eat
; 上述方式都称为依赖关系。DependencyAndRelation
进行绘制。 public class ExtendAndImplent { } abstract class Happy{ abstract void sayHi(); } class TodayHappy extends Happy { @Override void sayHi() { System.out.println("我今天很开心"); } } interface Operator{ public void opt(); } class AddOperator implements Operator { @Override public void opt() { System.out.println("我会加法"); } }
public class AggregationAndComposition { public static void main(String[] args) { Cat cat = new Cat(); } } class Cat{ private Appendage appendage; } class Appendage{ }
public class AggregationAndComposition { public static void main(String[] args) { Cat cat = new Cat(); } } class Cat{ private Appendage appendage = new Appendage(); } class Appendage{ }