您当前的位置: 首页 >  Java

壹小俊

暂无认证

  • 1浏览

    0关注

    885博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

java类的高级特性&包

壹小俊 发布时间:2021-06-26 21:51:58 ,浏览量:1

这个com/lzw就是包。

package com.lzw;

public class Math {
    public void test1(){
        System.out.println("this is math");
    }
    public static void main(String[] args) {
        System.out.println("this not is java.lang.Math class ,so this is com.lzw.Math class");
    }
}
import com.lzw.Math;
public class Test1 {
    public static void main(String[] args) {
        Math math = new Math();
        math.test1();
    }
}
public class Test2 {
    static final double PI = 3.14;

    public static void main(String[] args) {
        System.out.println(PI);
        Test2 test2 = new Test2();
        test2.test();
    }

    public final void test(){
        System.out.println("thisi is final function");
    }
}
final class Test3 {
    int a = 3;

    public static void main(String[] args) {
        Test3 test3 = new Test3();
        test3.a++;
        System.out.println(test3.a);
    }
}
public class Test4 {
    Test5 test5 = new Test5();
    public void test(){
        System.out.println(test5.a);
    }

    public static void main(String[] args) {
        Test4 test4 = new Test4();
       test4.test();
    }
    public class Test5{
        public int a = 5;
    }
}

关注
打赏
1664335782
查看更多评论
立即登录/注册

微信扫码登录

0.0369s