fork download
  1. class Foo {
  2. public static void main(String[] args) {
  3. Foo foo = new Foo();
  4. foo.run();
  5. }
  6.  
  7. private int i = 0;
  8. private int j = 18;
  9. public class Bar {
  10. private int j = -1;
  11. public void print() {
  12. System.out.println(i);
  13. }
  14. public void modify(int newValue) {
  15. i = newValue;
  16. }
  17. public void print2() {
  18. System.out.println(j);
  19. System.out.println(this.j);
  20. System.out.println(Foo.this.j);
  21. System.out.println(Bar.this.j);
  22. }
  23. }
  24. public void run() {
  25. this.i = 7;
  26. Bar bar = new Bar();
  27. bar.print();
  28. i = 2;
  29. bar.print();
  30. bar.modify(12);
  31. bar.print();
  32. System.out.println(this.i);
  33. System.out.println("---");
  34. bar.print2();
  35. }
  36. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
7
2
12
12
---
-1
-1
18
-1