This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Though I am not in any mood to start controversy here but looking for the best way to initialize the variables when we don't have the values to be assigned at run time.
In this situation, I can either initialize reference variables to Null, empty or left them uninitialized.
Though local and final variables will give compilation errors if left uninitialized so they have to be either empty or null initialized.
What is you call on the following ways of initializing variables. And how to handle erroneous conditions in a program regarding these initializations. Is it good to place null checks or checks for empty initializations.
What do you mean by reference variables? Do you mean fields? What does Null, empty or ... uninitialised mean?
If you have values which are uninitialised at runtime, why do you have those variables in the first place? If you have a final field which you are initialising to null, that looks like poor design to me. Get rid of whichever constructor initialises those values to null.