Site uses cookies to provide basic functionality.

OK
Example 6-11. Java Example of Enforcing a Singleton with a Private Constructor public class MaxId { // constructors and destructors private MaxId() { <-- 1 ... } ... // public routines public static MaxId GetInstance() { <-- 2 return m_instance; } ... // private members private static final MaxId m_instance = new MaxId(); <-- 3 ... } (1)Here is the private constructor. (2)Here is the public routine that provides access to the single instance. (3)Here is the single instance.