只要是在类中用到了对方,那么他们之间就存在依赖关系。如果没有对方,连编 绎都通过不了。

    1. package com.atguigu.uml.dependence;
    2. public class Person {
    3. }
    package com.atguigu.uml.dependence;
    
    public class PersonDao {
    
    }
    
    package com.atguigu.uml.dependence;
    
    public class IDCard {
    
    }
    
    package com.atguigu.uml.dependence;
    
    public class Department {
    
    }
    
    package com.atguigu.uml.dependence;
    
    public class PersonServiceBean {
        private PersonDao personDao;// 类
    
        public void save(Person person) {
        }
    
        public IDCard getIDCard(Integer personid) {
            return null;
        }
    
        public void modify() {
            Department department = new Department();
        }
    
    }
    

    对应的类图:

    image.png

    小结

    1)类中用到了对方
    2)如果是类的成员属性
    3)如果是方法的返回类型
    4)是方法接收的参数类型
    5)方法中使用到