1 package com.sam.demo01; 2 3 public class Test01 { 4 public void ShowTest01() { 5 System.out.println("我是Test01"); 6 } 7 }
1 package com.sam.demo01; 2 3 public class Test02 { 4 public void ShowTest02() { 5 System.out.println("我是Test02"); 6 } 7 }
1 module Demo01 { 2 //如何有其余模块依赖我,那么其余模块下面的1个包均可以访问 3 exports com.sam.demo01; 4 }
1 module Demo02 { 2 //如何有其余模块依赖我,那么其余模块下面的1个包能够访问 3 exports com.sam.demo02; 4 //我须要依赖Demo01模块,才能完成个人工做 5 requires Demo01; 6 }
1 package com.sam.demo02; 2 3 import com.sam.demo01.Test01; 4 5 public class TestMain { 6 public static void main(String[] args) { 7 Test01 test=new Test01(); 8 test.ShowTest01(); 9 } 10 }