Lazy Initialization



As the name implies the initialization for objects in lethargic routine, the creation of an object is hindered until the object is actually required for first usage in the program.

When the developer considers the construction of the object is very expensive when it is instantiated, then they can use the keyword Lazy in front of the object declaration.

Objectives


  • Improves the performance of the code execution
  • Avoid lavish calculation
  • Minimize the memory requirements


Syntax

Lazy (Type)

Declaration

Lazy lazyMobile = new Lazy();

No comments: