title: Switch Case statement Using Class level Variable
body: <p>How can I use a switch case statement using class level variable. </p>
  
  <pre><code>@Value("${user.name}")
  private static final String userName = "xyz";
  
  public static void main(String[] args) {
    String nn = "xyz";
    switch (nn) {
      case userName:
          System.out.println("It Works!!");
  
    }
  }
  
  </code></pre>
  
  <p>In the above example I have a class level variable called "userName" which is retrieving the value from properties file. To use this field in switch case statement I have to make it final and assign a value but it's not executing the case statement. 
  How can I use the class level variable in switch case statement? </p>