Skip to content

Instantly share code, notes, and snippets.

@Wicowyn
Last active September 26, 2016 16:14
Show Gist options
  • Save Wicowyn/4ba481b0afbdf84b88ce6c0045d4e457 to your computer and use it in GitHub Desktop.
Save Wicowyn/4ba481b0afbdf84b88ce6c0045d4e457 to your computer and use it in GitHub Desktop.
Java instance création
Property logger 1
Upper class constructor
Property logger 2
Sub class constructor
public class Main {
public static void main(String[] args) {
new SubClass();
}
}
//PropertyLogger.java
public class PropertyLogger {
public PropertyLogger(int count) {
System.out.println("Property logger "+count);
}
}
public class SubClass extends UpperClass {
PropertyLogger l2 = new PropertyLogger(2);
public SubClass() {
System.out.println("Sub class constructor");
}
}
public class UpperClass {
PropertyLogger l1 = new PropertyLogger(1);
public UpperClass() {
System.out.println("Upper class constructor");
}
}
@Wicowyn
Copy link
Author

Wicowyn commented Sep 26, 2016

Je m'attendais à :

Property logger 1
Property logger 2
Upper class constructor
Sub class constructor

Où comment re-découvrir Java x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment