Hi all, I can't understand the result of the following code:
The result o f the run is : r1 r4 pre b1 b2 r3 r2 aigle
I don't understand why the static code in class Rapace is executed before the instantiation of Aigle Object. This means that all the static code inside a project is executed during compilation? Or there's something related to inheritance between Oiseau/Rapace/Aigle objects since Aigle is inside the main method?
I am not positive, but i BELIEVE that each class is loaded just before it is needed for the first time. you may have a branch in your code that never needs certain classes, so (again, i think) those will never be loaded.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joined: Jan 02, 2007
in fact if I add a class that has nothing to do with the others, the static code is not executed :
"reptile" is not printed out.
So maybe the jvm is so intelligent to know, before invoking main method, all the classes that will be directly involved in the execution... is that right?