Quote
--------------------------------------------------------------------------
And just slightly better:
code:
--------------------------------------------------------------------------------
private static final SingletonExample instance = new SingletonExample();
--------------------------------------------------------------------------------
---------------------------------------------------------------------------
above code can be considered when you have multithreade enviornment.
you need to add some synchronization check in your getinstance method ,which will prevent race condition.
lazy creation of object gives you better performance when you do not require the object frequently.There it gives performance benefit.
Examples of singleton , Runtime class in
java is singleton,Printer,there are other several examples of singleton.
________________________
Mintoo
SCJP 1.4
____________________________