title: Setters / Getters within singleton in Java
body: <p>I need to create working setters/getters for a application, that will use few different classes. This classes will use one class, that will store all data. I know, when I will use standard constructor of container class, I'll get tons on nulls, due to different instance of container class.</p>
  
  <p>I've created container class within a singleton, that works, but I wanted to ask, anything could be done better. My code:</p>
  
  <p>Container.java:</p>
  
  <pre><code>public class Container {
  
      public static final String String = "Welcome in Singleton Container\n";
      private String Test = null;
      private String appName = null;
      private String appOwner = null;
  
      private Container(String mes) {
          System.out.println("Message from Container: " + mes);
      }
  
      private static class SingletonHolder {
          private final static Container INSTANCE = new Container(String);
      }
  
      public static Container getInstance() {
          return SingletonHolder.INSTANCE;
      }
  
      public String getTest() {
          return Test;
      }
  
      public void setTest(String test) {
          Test = test;
      }
  
      public String getAppName() {
          return appName;
      }
  
      public void setAppName(String appName) {
          this.appName = appName;
      }
  
      public String getAppOwner() {
          return appOwner;
      }
  
      public void setAppOwner(String appOwner) {
          this.appOwner = appOwner;
      }   
  }
  </code></pre>
  
  <p>Sample class, that will use this container:</p>
  
  <pre><code>public class SecondClass {
  
      Container ctn = Container.getInstance();
      .
      .
      some methods...
  }
  </code></pre>
  
  <p>Right now, when I use in main class ie.: </p>
  
  <pre><code>ctn.setAppOwner(owner);
  </code></pre>
  
  <p>I get a proper value in any other classes, when I call this:</p>
  
  <pre><code>Container ctn = Container.getInstance();
  ctn.getAppOwner();
  </code></pre>
  
  <p>Is that a good approach?</p>