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. class Ideone
  9. {
  10. public static void main(String[] args) {
  11. new B(6);
  12. }
  13.  
  14. public static class A {
  15. private int f1 = 7;
  16.  
  17. public A(int f1) {
  18. this.f1 = f1;
  19. initialize();
  20. }
  21.  
  22. protected void initialize() {
  23. System.out.println("A init");
  24. System.out.println(f1);
  25. }
  26. }
  27.  
  28. public static class B extends A {
  29. protected int f1 = 3;
  30. public B(int f1) {
  31. super(f1);
  32. this.f1 += f1;
  33. initialize();
  34. }
  35.  
  36. protected void initialize() {
  37. System.out.println("B init");
  38. System.out.println(f1);
  39. }
  40. }
  41. }
Success #stdin #stdout 0.07s 2841600KB
stdin
Standard input is empty
stdout
B init
0
B init
9