title: How to randomly select a string between two strings from ENUM in java?
body: <p>I have two strings which are mentioned below - </p>
  
  <pre><code>HelloWorld 
  GoodBye
  </code></pre>
  
  <p>How do I randomly select any one of the strings?</p>
  
  <p>Below is an enum which contains the above two strings and I am supposed to use below enums to randomly select any one of the string  between <code>HelloWorld</code> and <code>GoodBye</code></p>
  
  <pre><code>public enum StringEnum {
      HelloDavid, HelloWorld, GoodBye;
  
      private static final Map&lt;Integer, StringEnum&gt; BY_CODE_MAP = new LinkedHashMap&lt;Integer, StringEnum&gt;();
  
      static {
      for (StringEnum rae : StringEnum.values()) {
          BY_CODE_MAP.put(rae.ordinal(), rae);
      }
      }
  
      public static String forCode(int code) {
      return BY_CODE_MAP.get(code).name();
      }
  }
  </code></pre>
  
  <p>Any idea how this can be done efficiently by getting the strings from enum?</p>