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. {
  10. private static int foo = 0;
  11. private static int returnStuff() {
  12. return foo++;
  13. }
  14.  
  15. private static boolean bar = false;
  16. private static boolean returnStuff2() {
  17. boolean beforeChange = bar;
  18. bar = !bar;
  19. return beforeChange;
  20. }
  21.  
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. System.out.println("value before: " + foo);
  25. System.out.println("returned: " + returnStuff());
  26. System.out.println("value afterwards: " + foo);
  27.  
  28. System.out.println("value before: " + bar);
  29. System.out.println("returned: " + returnStuff2());
  30. System.out.println("value afterwards: " + bar);
  31. }
  32. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
value before:     0
returned:         0
value afterwards: 1
value before:     false
returned:         false
value afterwards: true