fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. enum TrickyEnum
  8. {
  9. TrickyEnum1, TrickyEnum2;
  10.  
  11. static int count = 123;
  12.  
  13. TrickyEnum()
  14. {
  15. incrementCount();
  16. }
  17.  
  18. private static void incrementCount()
  19. {
  20. count++;
  21. System.out.println("Count: " + count);
  22. }
  23.  
  24. public static void showCount()
  25. {
  26. System.out.println("Count: " + count);
  27. }
  28. }
  29. /* Name of the class has to be "Main" only if the class is public. */
  30. class Ideone
  31. {
  32. public static void main (String[] args) throws java.lang.Exception
  33. {
  34. TrickyEnum te = TrickyEnum.TrickyEnum1;
  35. TrickyEnum.showCount();
  36. }
  37. }
Success #stdin #stdout 0.06s 380160KB
stdin
Standard input is empty
stdout
Count: 1
Count: 2
Count: 123