| Author |
Initialize primtive and Object variables
|
Raj Puri
Ranch Hand
Joined: Apr 24, 2003
Posts: 189
|
|
I understand object variables get intialized to NULL if you do not initialize them explicitly and accessing them will give null pointer exception where as this does not happen for primtive variables as get their values to defaults automatically. Is that a good understanding?
|
 |
Jose Botella
Ranch Hand
Joined: Jul 03, 2001
Posts: 2120
|
|
The null value can be considered the default value for reference variables. In addition: Only the member variables get automatically initialized to default values; local variables are not. However, the components of an array are initialized to default values even when the array was local to a method.
|
SCJP2. Please Indent your code using UBB Code
|
 |
 |
|
|
subject: Initialize primtive and Object variables
|
|
|