1 // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file 2 // for details. All rights reserved. Use of this source code is governed by a 3 // BSD-style license that can be found in the LICENSE file. 4 package instancevariable; 5 6 class InstanceVariable { 7 public int foo = 42; 8 public int bar; 9 public InstanceVariable parent; 10 11 private int privateFoo; 12 private int privateBar = -1; 13 private InstanceVariable privateParent; 14 InstanceVariable()15 public InstanceVariable() {} 16 InstanceVariable(int bar)17 public InstanceVariable(int bar) { 18 this.bar = bar; 19 privateFoo = 1; 20 privateBar = 43; 21 parent = new InstanceVariable(); 22 privateParent = new InstanceVariable(); 23 } 24 sumAll()25 public int sumAll() { 26 return privateFoo + privateBar + bar + foo + parent.foo + privateParent.privateBar; 27 } 28 main(String[] args)29 public static void main(String[] args) { 30 InstanceVariable instanceVariable = new InstanceVariable(17); 31 System.out.println(instanceVariable.sumAll() + "=144"); 32 } 33 } 34