java进阶 package包29

 

 

 

package com.cyjt97.a;

public class studer {
    public static void main(String[] args) {
        cf();
    }

    private static void cf() {
        System.out.println("吃饭");
    }
}
package com.cyjt97.b;

public class studer {
    public static void main(String[] args) {
        seel();
    }

    private static void seel() {
        System.out.println("睡觉");
    }
}
package com.cyjt97.test;

import com.cyjt97.a.studer;

public class t {
    public static void main(String[] args) {
        studer stu1 = new studer();
//        导包类名相同时,用权类名创建对象
//        包名+类名
        com.cyjt97.b.studer stu2 = new com.cyjt97.b.studer();


    }
}

  

 

posted @ 2023-03-10 11:20  文采呱呱  阅读(9)  评论(0编辑  收藏  举报