T
thechaosengine
Hi everyone,
I posted a question earlier about a collection class that I'd made seemingly
getting instantiated magically after a class that contained a variable of
that type had its constructor called.
The constructor didnt touch the collection class and defineately didn't
initialise it.
Some one suggested the following reason as what is happening.
If anyone can help with what I've said down below i'd be very greatful:
Thanks
I'm not really sure what to make of that. How come, if I dont initialise, by
means of a constructor, a string for example - its null until I give it
something?
Thanks
I posted a question earlier about a collection class that I'd made seemingly
getting instantiated magically after a class that contained a variable of
that type had its constructor called.
The constructor didnt touch the collection class and defineately didn't
initialise it.
Some one suggested the following reason as what is happening.
If anyone can help with what I've said down below i'd be very greatful:
Thanks
Field initialization
The initial value of a field, whether it be a static field or an instance
field, is the default value (§5.2) of the field's type. It is not possible
to observe the value of a field before this default initialization has
occurred, and a field is thus never "uninitialized".
I'm not really sure what to make of that. How come, if I dont initialise, by
means of a constructor, a string for example - its null until I give it
something?
Thanks