3Fermer5
SCPCDLe 10/09/2013 à 09:49
effectivement la variable est initialisée plusieurs fois, je ne le savais pas non plus.
(vu en faisant du pas-à-pas)

lien qui confirme :
http://www.artima.com/designtechniques/initializationP.html
=>
"Note that this means that if you explicitly initialize innerCoffee, say to a value of 100, then when each CoffeeCup object is created, innerCoffee will, in effect, be initialized twice. First, innerCoffee will be given its default initial value of zero. Later, the zero will be overwritten with the proper initial value of 100. All of this takes place while the Java virtual machine is creating the new object -- before it returns the reference to the new object. By the time the reference to a new CoffeeCup object is returned from the new operator, the innerCoffee field will be set to 100"

confirmé sur le site d'oracle :
http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html
(voir exemple 12.5-1)


bon à savoir en tout cas :/