1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
package 面向对象;
public class TestStatic { int a; int b; static int x; static int y; void func1() { System.out.println(a); System.out.println(b); System.out.println(x); System.out.println(y); System.out.println("普通成员方法func1"); func2(); } static void func2() { System.out.println("static成员方法func2"); } public static void main(String[] args) { TestStatic obj = new TestStatic(); x = 1; System.out.println(x); System.out.println(TestStatic.x); func2(); TestStatic.func2(); TestStatic obj1 = new TestStatic(); TestStatic.x ++; System.out.println(TestStatic.x); } }
|