变量的声明

public class Test {
    
    //成员变量
    public int i;
    
    //静态变量(类的变量)
    public static int j;

    public void method() {
        //局部变量
        int i = 3;
        System.out.println(i);
    }
    
    public static void main(String[] args) {
        Test t = new Test();
        t.i = 1;
        System.out.println(t.i);
        
        t.j = 2;
        System.out.println(t.j);
        Test.j = 2;
        System.out.println(Test.j);
        
        t.method();
    }

}

猜你喜欢

转载自www.cnblogs.com/xiaotao520/p/9130441.html