aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Initialize primtive and Object variables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Initialize primtive and Object variables" Watch "Initialize primtive and Object variables" New topic
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: Initialize primtive and Object variables
 
Similar Threads
answers needed urgently about wrapper classes & grid lay out
Question on Integer type
Getting an exception(Serialization)
Difference between ArrayList<int> and ArrayList<Integer>
Servlets & Beans