Possible Duplicate:
String is not equal to string?
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#.
Scanner input = new Scanner(System.in);
System.out.println("Enter ID :");
String employeeId = input.nextLine();
int index = -1;
for(int i = 0 ; i < employeeCounter ; i++)
{
if(employeeId == employeeNumber[i])
{
index = i;
}
}
if(index == -1)
{
System.out.println("Invalid");
return;
}
I always get to the 'Invalid' part. Any idea why ? Thanks in advance
employeeNumber[0]
is "12345"
employeeId
is "12345"
but I can,t get into the first if statement although employeeId
IS equal to employeeNumber[0]
.