title: How to initialize my singleton object
body: <pre><code>public class FooClient {
  
      private Foo foo;
      private final static String key = "&lt;api-key&gt;";
  
      private static FooClient client = new FooClient();
  
      private FooClient() {
          foo = new Foo(key);
      }
  
      public static FooClient getFooClient() {
          return client;
      }
  }
  </code></pre>
  
  <ol>
  <li>Is it ok to initialize <code>client</code> in the above fashion.</li>
  <li>Should I declare private Foo foo; as static, I am guessing its not the case.</li>
  <li>If I have to support different singletons for different keys, should I modify <code>getFooClient(String key)</code> to take in a key and cache it, so that I can return singleton FooClients which are key specific.</li>
  </ol>