[Solved] Proper variable initialization and call from another class


  1. 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 of null until it is set at some later time setVar1
  2. No, you will not get an exception. If you try to call getVar1 before you call handle, you will get the default null value.

0

solved Proper variable initialization and call from another class