Frage im Vorstellungsgespräch bei Bloomberg

Implement singleton

Antworten zu Vorstellungsgespräch

Anonym

8. März 2010

In C#: public sealed class Singleton { private static Singleton s_instance = new Singleton(); // Make the constructor private so that no new instance can be generated from outside private Singleton() {} public Singleton GetInstance() { return s_instance(); } }

Anonym

17. Jän. 2013

public class A { private static final A singleton = new A(); private A() {} public static A getInstance() { return singleton; } }

Anonym

22. Nov. 2009

pretty simple