- No, both examples are not equal. In example one the variable is initialized at construction time and
class1
cannot be instantiated without it. In example 2, the variable is not initialized and is given the default value ofnull
until it is set at some later timesetVar1
- No, you will not get an exception. If you try to call
getVar1
before you callhandle
, you will get the defaultnull
value.
0
solved Proper variable initialization and call from another class