Mals Raj wrote:Yes, the idea is to delay the creation of an object as this creation could be expensive depending on the circumstances. It could be I guess assigning a new value to a variable, populating a list from a db call, initialising a new object etc.
below is a very basic example
If you'll allow me to be slightly anal that should probably be :
Which would allow other bits of code that do not necessarily require the list to be populated to use the collection instance (i.e. code like listOfObjects.contains(mySpecificItem) would not require a null check).
:p