Why don't strings compare as equal?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7128775/string-is-not-equal-to-string">String is not equal to string?</a>  </p>
</blockquote>



<p>I'm new to java and I can't figure out what's wrong with this code block.
I know the array isn't null i'm testing it elsewhere. Maybe there is a syntax problem i'm used to program in c#.</p>

<pre><code>     Scanner input = new Scanner(System.in);
     System.out.println("Enter ID :");
     String employeeId = input.nextLine();
     int index =  -1;
     for(int i = 0 ; i &lt; employeeCounter ; i++)
     {
         if(employeeId == employeeNumber[i])
         {
           index = i;
         }
     }

     if(index == -1)
     {
         System.out.println("Invalid");
         return;
     }
</code></pre>

<p>I always get to the 'Invalid' part. Any idea why ?
Thanks in advance</p>

<hr>

<p>employeeNumber[0] is "12345"
employeeId is "12345"
but I can,t get into the first if statement although employeeId IS equal to employeeNumber[0].</p>
