paul@54 | 1 | public class FieldTest { |
paul@54 | 2 | private int a; |
paul@54 | 3 | protected int b = 123; |
paul@54 | 4 | protected FieldTestClass c; |
paul@54 | 5 | protected FieldTestClass d = null; |
paul@54 | 6 | public FieldTestClass e = new FieldTestClass(456); |
paul@57 | 7 | public FieldTestClass f = new FieldTestClass(b + e.a); |
paul@57 | 8 | public static FieldTestClass g; |
paul@57 | 9 | public static FieldTestClass h = new FieldTestClass(789); |
paul@143 | 10 | |
paul@143 | 11 | public static void main(String[] args) { |
paul@143 | 12 | if (FieldTest.h != null && FieldTest.h.a == 789) { |
paul@143 | 13 | System.out.println("FieldTest.h.a correct: " + FieldTest.h.a); |
paul@143 | 14 | } else { |
paul@143 | 15 | System.out.println("FieldTest.h.a failed!"); |
paul@143 | 16 | } |
paul@143 | 17 | FieldTest test = new FieldTest(); |
paul@143 | 18 | if (test.h != null && test.h.a == 789) { |
paul@143 | 19 | System.out.println("test.h.a correct: " + test.h.a); |
paul@143 | 20 | } else { |
paul@143 | 21 | System.out.println("test.h.a failed!"); |
paul@143 | 22 | } |
paul@143 | 23 | if (test.e != null && test.e.a == 456) { |
paul@143 | 24 | System.out.println("test.e.a correct: " + test.e.a); |
paul@143 | 25 | } else { |
paul@143 | 26 | System.out.println("test.e.a failed!"); |
paul@143 | 27 | } |
paul@143 | 28 | if (test.f != null && test.f.a == 579) { |
paul@143 | 29 | System.out.println("test.f.a correct: " + test.f.a); |
paul@143 | 30 | } else { |
paul@143 | 31 | System.out.println("test.f.a failed!"); |
paul@143 | 32 | } |
paul@143 | 33 | } |
paul@54 | 34 | } |
paul@54 | 35 | |
paul@54 | 36 | class FieldTestClass { |
paul@54 | 37 | public int a; |
paul@54 | 38 | |
paul@54 | 39 | public FieldTestClass(int a) { |
paul@54 | 40 | this.a = a; |
paul@54 | 41 | } |
paul@54 | 42 | } |
paul@143 | 43 | |
paul@143 | 44 | // vim: tabstop=4 expandtab shiftwidth=4 |