This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes difference between class is loaded and class is instantiated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between class is loaded and class is instantiated" Watch "difference between class is loaded and class is instantiated" New topic
Author

difference between class is loaded and class is instantiated

prakash praksh
Greenhorn

Joined: Oct 22, 2009
Posts: 2
Please help me to understand the following:

If no initialization is provided for a static variable either in the declaration or in a static initializer block, it is initialized with the default value of its type when the class is loaded.

Similarly, if no initialization is provided for an instance variable either in the declaration or in an instance initializer block it is initialized with the default value of its type when the class is instantiated.


What is the difference between class is loaded and class is instantiated ?



Thanks,
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Welcome to JavaRanch

A class is loaded when it is required for the application. A class is instantiated whenever an object is created from it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: difference between class is loaded and class is instantiated
 
Similar Threads
instance variable declarations, when do they occur?
Interesting mock question about arrays and postfix
static initializers v static blocks.
final instance variable
my notes on JLS for any1 who needs them !!