fork download
  1. class Demo {
  2. private int foo;
  3. Demo(int i) { foo = i; }
  4. public void accessOther(Demo other) { System.out.println(other.foo); }
  5.  
  6. public static void main(String[] args) {
  7. Demo one = new Demo(1);
  8. Demo two = new Demo(2);
  9. two.accessOther(one);
  10. }
  11. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
1