aspose file tools*
The moose likes Beginning Java and the fly likes lazy initialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "lazy initialization " Watch "lazy initialization " New topic
Author

lazy initialization

basia fish
Greenhorn

Joined: Aug 04, 2003
Posts: 17
hi

how do i use lazy initialization
how would it change code like this

private int array[];

public void setArray(int arr[])
{
array=arr;
}
public int[] getArray)()
{
return array;
}

help really apprecaited
thanks a lot
barb
Dipen Javia
Greenhorn

Joined: Jun 12, 2004
Posts: 5
Hey barb,

I am sorry barb but i couldnt understand what you are trying to do with that code and I didnt understand the term "lazy initialization".


Dipen Javia.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Lazy instantiation/initialisation means you don't initialise a member until the first time that member is requested somewhere.

Typically you'd have something like


Typically it's used when the initialisation of the data is expensive and won't be required for every instance of the class. Using lazy instantiation in such cases yields a performance win for many users of the class either by using less CPU cycles and/or less memory.


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: lazy initialization
 
Similar Threads
fields of visibility
lazy initialization
how to access the elements of multidimension array using for each loop?
How to create multidimension array using for each loop?
final variable in a for loop