在静态方法中不可以使用this关键字
在静态方法中不可以调用非静态方法
在非静态方法中可以调用静态方法
在静态方法中不可以调用super
- public
class Test { -
static { -
_i = 20; -
} -
public static int _i = 10; -
-
public static void main(String[] args) { -
System.out.println(_i); -
} - }
输出10;
上述代码等价于:
- public
class Test { -
public static int _i; -
-
static { -
_i = 20; -
_i = 10; -
} -
-
public static void main(String[] args) { -
System.out.println(_i); -
} - }