ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

Why SingleTon ?

We should not create the object’s unnecesarly. Because if there are no instance variables still it allocates 8 bytes. If there are no instance variables and if there are N number of methods then all the methods should be declared as static. Instead of declaring all the methods as static, lets declare them as non static and construct only one object and use the object in all the flows.
            Steps for the 1st way :
                        1.declare a private constructor.
                        2.create an object using static.
                        3.write a static method to get the object.
            Steps for the 2nd way :
                        1.write a default private constructor.
                        2.create static reference variable.
                        3.write a static method to return the object.
                        3.1.check the static ref is pointing an object or not.
           3.2.If it is pointing to null then create the object and assign to static                                            ref.**
Related Posts Plugin for WordPress, Blogger...
Flag Counter