title: java 8: difference between class.getName() and String literal
body: <p>I was working on switch case. </p>
  
  <p>If we use class.getName(), then, I am getting error that "case expressions must be constant expressions" as follows:</p>
  
  <pre><code>switch(param.getClass().getName())
      {
          case String.class.getName():
              // to do
              break;
      }
  </code></pre>
  
  <p>Even if we do following, take string class name in a constant, then also, getting  same error:</p>
  
  <pre><code>public static final String PARAM_NAME = String.class.getName();
  switch(param.getClass().getName())
      {
          case PARAM_NAME:
              // to do
              break;
      }
  </code></pre>
  
  <p>But, if I do following, use the string literal "java.lang.String", there is not error:</p>
  
  <pre><code>public static final String PARAM_NAME = "java.lang.String";
  </code></pre>
  
  <p>Can anybody please explain this, why its not taking first two cases and taking the last one? Thanks in advance.</p>