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. class Ideone {
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. static class Base {
  11. static {
  12. System.out.println("Base");
  13. }
  14. }
  15. static class Derived extends Base {
  16. static {
  17. System.out.println("Derived");
  18. }
  19. public static int foo = 2;
  20. }
  21.  
  22. static class Derived2 extends Derived {
  23. static {
  24. System.out.println("Derived2");
  25. }
  26. }
  27.  
  28. public static void main(String[] args) {
  29. System.out.println(Derived2.foo);
  30. }
  31. }
Success #stdin #stdout 0.08s 52600KB
stdin
Standard input is empty
stdout
Base
Derived
2