2. * Creating a singleton java class in an application is also needed. There are a lot of objects
that only need a single instance that’s why it is called Singleton.
* Some example is when you are creating an object driver in connecting to an API. From my
experience, i created a single instance of a connection going to an API because the server
can’t handle multiple request or else the server of the host will fall. Even though you can
create a multiple instance so that transaction will be processed asynchronously.
3. * the first example is the class is initialized as static.
* the class also created a private constructor so no other
object or class can create an instance of this class.
* the class also created a private constructor so no other
object or class can create an instance of this class.
4. * also we used the word synchronized so that this will fit in a multithreaded
environment.
* one cons for this implementation is that this may affect the perfomarnce
of the application
* one cons for this implementation is that this may affect the perfomarnce
of the application
5. * we can also used this technique by checking first if there is
an instance of the class then that is the time we could do
synchronized. this might help now with the performance.
6. * I can say it is important that you also know how to write a singleton
class so that you will know when you can used this singleton classes.
This is important so you can managed the classes running in your
application without having deep usage of the memory