模块的基本使用

 

 

由于不在同一模块下 无法直接调用就需要

 

 

在src目录右击新建module-info.java

/**
* FileName: module-info
* Author: lps
* Date: 2022/4/12 12:28
* Sign:刘品水 Q:1944900433
*/module myOne {
exports com.iot1913;
exports com.iot1921;
}


/**
* FileName: module-info
* Author: lps
* Date: 2022/4/12 12:28
* Sign:刘品水 Q:1944900433
*/module myTwo {
requires myOne;
}

package com.iot1913;

/**
 * FileName: Student
 * Author:   lps
 * Date:     2022/4/12 12:22
 * Sign:刘品水 Q:1944900433
 */
public class Student {
    public void study(){
        System.out.println("好好学习 天天向上");
    }
}
package com.iot1921;

/**
 * FileName: Teacher
 * Author:   lps
 * Date:     2022/4/12 12:24
 * Sign:刘品水 Q:1944900433
 */
public class Teacher {
    public void teach() {
        System.out.println("键盘敲烂 月薪过万");
    }
}
package iot1913;

import com.iot1913.Student;
import com.iot1921.Teacher;

/**
 * FileName: Test01
 * Author:   lps
 * Date:     2022/4/12 12:24
 * Sign:刘品水 Q:1944900433
 */
public class Test01 {
    public static void main(String[] args) {
        Student s = new Student();
        s.study();

        Teacher t=new Teacher();
        t.teach();

    }
}

 

posted @ 2022-04-12 12:51  刘品水  阅读(29)  评论(0编辑  收藏  举报