fork(8) download
  1. // filename: Test2.java
  2. class Test1 {
  3. Test1(int x) {
  4. System.out.println("Constructor called " + x);
  5. }
  6. }
  7.  
  8. // This class contains an instance of Test1
  9. class Test2 {
  10. Test1 t1 = new Test1(10);
  11.  
  12. Test2(int i) { t1 = new Test1(i); }
  13.  
  14. public static void main(String[] args) {
  15. Test2 t2 = new Test2(5);
  16. }
  17. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
Constructor called 10
Constructor called 5