fork(1) download
  1. class TestInitOrder {
  2. static {
  3. System.out.println(TestInitOrder.stat1);
  4. System.out.println(TestInitOrder.stat2);
  5. System.out.println(TestInitOrder.str);
  6. System.out.println(TestInitOrder.str2);
  7.  
  8. str = "something";
  9.  
  10. System.out.println(TestInitOrder.str);
  11. System.out.println(TestInitOrder.str2);
  12. System.out.println(TestInitOrder.lazy);
  13. System.out.println(TestInitOrder.second);
  14. }
  15.  
  16. private static final int stat1 = 10;
  17. static final String str2 = "sdfff";
  18. static String str = "crap";
  19. private static int stat2 = 19;
  20. static final Second second = new Second();
  21. static final int lazy;
  22.  
  23. static {
  24. lazy = 20;
  25. }
  26.  
  27. static {
  28. System.out.println(TestInitOrder.str2);
  29. System.out.println(TestInitOrder.stat2);
  30. System.out.println(TestInitOrder.str);
  31. System.out.println(TestInitOrder.lazy);
  32. System.out.println(TestInitOrder.second);
  33. }
  34.  
  35. public static void main(String args[]) {
  36. }
  37.  
  38. }
  39.  
  40. class Second {
  41. public Second() {
  42. System.out.println(TestInitOrder.second);
  43. }
  44. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
10
0
null
sdfff
something
sdfff
0
null
null
sdfff
19
crap
20
Second@addbf1