Effective Java Study Note - Enforce the singleton property with a private constructor or an enum type
There are 2 common ways to implement singleton, one is to provide a public static factory method, the other one is to have a public final field. There is also an approach to provide singleton: A single value enum(preferred approach).
No comments:
Post a Comment