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. public class Main
  9. {
  10. public static void main(String[] args)
  11. {
  12. A a1=new A();
  13. A a2=new A();
  14. B b1=new B();
  15. }
  16. }
  17.  
  18. class A
  19. {
  20. {System.out.println("Non-Static block of a instance of Class A");}
  21. public A()
  22. {
  23. System.out.println("Constructing object of type A");
  24. }
  25. }
  26.  
  27. class B
  28. {
  29. {System.out.println("Non-Static block of a instance of Class B");}
  30. public B()
  31. {
  32. System.out.println("Constructing object of type B");
  33. }
  34. }
Success #stdin #stdout 0.07s 54600KB
stdin
Standard input is empty
stdout
Non-Static block of a instance of Class A
Constructing object of type A
Non-Static block of a instance of Class A
Constructing object of type A
Non-Static block of a instance of Class B
Constructing object of type B