However it does not go into using a Singleton class from what I can tell. To get the most out of this you may want to start here at this point in the Java trail:
1. Better is to ask question in a post rather than subject line. For a reason so you could provide more details.
2. As you see from the replies you got so far, your question wasn't clear or not clear enough to provide clear answer/-s.
Please use post area to provide full details about what you mean, so the guys wouldn't need to make guesses on what you mean.
An example would be on a helpful side.
As we know that Singleton pattern is used for Loggers, caching etc. I need an example of singleton pattern (using Enum) to implement a Logger class in a project.
thanks for your help.
Arun Singh Raaj wrote:singleton pattern (using Enum) to implement a Logger class
When you say implement Logger class, you mean your own logging framework?
Consider using existing logging frameworks as Apache Log4j 2. I'd be doubted you could easily come up with something better than that.
Arun Singh Raaj wrote:I need an example
If you enhance the concept of singletons to include classes with fixed numbers of distinct instances, isn't that what an enum is? Every enum ever seen matches that description.
The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects.
I'm not sure which parts of a logging framework you think are (or should be) singletons - log4j, for example, uses static members in each class. Would those not serve your purposes?
Also, I second Liutauras' suggestion to use an existing logging framework instead of rolling your own.
Assume, I developed an e-commerce application, if I make a particular class(Shopping Cart-class) Singleton in project, then will this class return one object per customer or a single object in the entire application for all customers?
I mean, Singleton refers single object per client or only object for all the clients?