fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone {
  9. private static class A {
  10. public int i;
  11. public A(int i) {
  12. this.i = i;
  13. }
  14. }
  15.  
  16. public static void foo(A a) {
  17. a.i += 2;
  18. System.out.println("foo: " + a.i);
  19. }
  20.  
  21. public static void main (String[] args) throws java.lang.Exception
  22. {
  23. int j = 10;
  24. System.out.println("main1: " + j);
  25. A a = new A(j);
  26. foo(a);
  27. j = a.i;
  28. System.out.println("main1: " + j);
  29. }
  30. }
Success #stdin #stdout 0.09s 55652KB
stdin
Standard input is empty
stdout
main1: 10
foo: 12
main1: 12