title: Switch String with Enum variables
body: <p>I have got an Enum with different values and want to switch a string variable. Now I hit a wall trying to convert the Enum values to Strings, that I can use as case constant. </p>
  
  <p>My best try was to convert the Enum to a String array, but the switch doesn't seem to accept array values as a case constant. (IntelliJ says: "constant expression required")</p>
  
  <pre><code>Enum myEnum = {FOO, BAR}
  
  String input = "foo"
  
  final String[] constant = Arrays.stream(myEnum.values()).map(Enum::name).toArray(String[]::new); 
  //converts Enum to String[]; made it final, so it is "constant" 
  
         switch (input) {
                      case constant[0]:
                          System.out.println("foo");
                          break;
                      case constant[1]:
                          System.out.println("bar");
                          break;
                       }
  </code></pre>
  
  <p>Is there an elegant way to make this switch depend on the Enum?</p>