title: Better way to keep String type values globally?
body: <p>I want some String values to be available/accessible to me throughput the application in Java. Different classes will need them. I want to know the best possible way to keep and access those values throughout the application.</p>
  
  <ol>
  <li><p>One way I know is to use Enum pattern in Java. Where I can associate a String value with each enum and then access it. Like given here. <a href="https://stackoverflow.com/questions/3978654/java-string-enum">Best way to create enum of strings?</a></p></li>
  <li><p>Second is to maintain a class of constants with String values.</p></li>
  </ol>
  
  <p>What is the possible best way so that good design will be followed and everything will be accessed cleanly.</p>
  
  <p>I would like to know.</p>
  
  <pre><code>public class StringValues
  {
     public static final String ONE = "one";
     public static final String TWO = "two";
  }
  </code></pre>
  
  <p>I am adding a little more detail.</p>
  
  <p>I am going to <strong>create DB queries</strong> with these short name Strings. So while instantiating database <em>I will use all the Strings in one place and will create queries</em>. </p>
  
  <p>But after query creation I will need a fragment/part of that String pool for a specific class so that I can register listener for the selected class not for all the Strings in the pool. Every class should know that It needs only 1-2 Strings names to register runtime listener not all the String names.</p>
  
  <p>I need all Strings at one time(during start of application) then I will just need 2 or 3 or more of them but not all.</p>
  
  <p>Here is the code to make you understand my exact design problem.</p>
  
  <pre><code>/**
  *This class will be used to create Views in Database.
  */
  class Views
  {
      public static final String BY_NAME = "byName";
      public static final String BY_DATE = "byDate";
      public static final String BY_GENDER = "byGender";
  
      //For every String I am going to create Views in Couchbase.
  }
  
  /**
  *This class knows to which Views it needs to listen to. If any change in its views occurs then
  * it will take action. In case of byDate change it is intended to take an action.
  */
  public class NewestMember
  {
      String[] viewsToQueryFor = {"byDate"};
  
      //This class will call only these views and will register for them.
  }
  
  
  public class Male
  {
      String[] viewsToQueryFor = {"byName", "byGender"};
  
      //This class will call only these views and will register for them.
  }
  
  
  public class Female
  {
      String[] viewsToQueryFor = {"byName", "byGender"};
  
      //This class will call only these views and will register for them.
  }
  </code></pre>
  
  <p>I do not want to do this. For this I have extra overhead of keeping String values in other classes.</p>