title: Java, "pointer" equality and string comparison
body: <p>I've C code that use a lot of commands identified by static string constants.</p>
  
  <pre><code>static char* KCmdA = "commandA"
  static char* KCmdB = "commandB"
  static char* KCmdC = "commandC"
  </code></pre>
  
  <p>In C I can compare two strings with strcmp(A, B) for example but as I only refer those command via their static string identifier it's faster to only check for pointer inequality since I know my unknowCMD can only be a pointer to one of my static strings.</p>
  
  <pre><code>switch(unknowCMD)
  {
      case KCmdA:
      ...
      case KCmdB:
      ...
  }
  </code></pre>
  
  <p>I guess in Java the equivalent to strcmp would be the method equals:</p>
  
  <pre><code>unknowCMD.equals(KCmdA)
  </code></pre>
  
  <p>Is there an equivalent of the pointer equality in Java ? I know Java uses only references. Is it possible to use those references for equality test without actually comparing the strings ?</p>
  
  <p>Sorry if this is obvious I've check the doc but did not find any definitive answer.</p>