title: Java Enum to find the Values givng null
body: <p>I have following code: I want to get value <code>Approved</code> when I pass <code>A</code>, and if I passed <code>R</code> then I should get <code>Reject New</code> but its not working and giving me null value.</p>
  
  <pre><code>public enum MyEnum {
      A("Approved"),
      R("Reject New"),
  
      private String status;
  
      private MyEnum(String status) {
          this.status = status;
      }
  
      public String getStatus() {
          return status;
      }
  
      public static MyEnum fromString(String text) {
          return Arrays.stream(values())
            .filter(v -&gt; v.status.equalsIgnoreCase(text))
            .findFirst()
            .orElse(null);
      }
  }
  </code></pre>
  
  <p>Another Code:</p>
  
  <pre><code>public class Demo {
      public static void main(String[] args) {
          System.out.println(MyEnum.fromString("A"));
      }
  }
  </code></pre>