fork download
  1. class Test
  2. {
  3. static int a;
  4.  
  5. static
  6. {
  7. a = 4;
  8. System.out.println ("inside static block\n");
  9. System.out.println ("a = " + a);
  10. }
  11.  
  12. Test()
  13. {
  14. System.out.println ("\ninside constructor\n");
  15. a = 10;
  16. }
  17.  
  18. public static void func()
  19. {
  20. a = a + 1;
  21. System.out.println ("a = " + a);
  22. }
  23.  
  24. public static void main(String[] args)
  25. {
  26.  
  27. Test obj = new Test();
  28. obj.func();
  29.  
  30. }
  31. }
Success #stdin #stdout 0.12s 53596KB
stdin
Standard input is empty
stdout
inside static block

a = 4

inside constructor

a = 11