22 Oct
2014
22 Oct
'14
10:56 p.m.
Hi, This is weird behavior I think: -------------------- public class Foo { 1 => static int bar; } <<< Foo.bar >>>; // prints 0! Why? Foo f; <<< Foo.bar >>>; // prints 1, ok 2 => Foo.bar; <<< Foo.bar >>>; // prints 2, ok Foo f2; <<< Foo.bar >>>; // prints 1 again! -------------------- So it seems that static members get initialized only on instantiation, but to make it funky, on every instantiation... Is this a buggy implementation of static members, or am I missing something? Not complaining, just a question. :) Thanks! Gonzalo