Possible duplicate:
Is the string not equal to the string?
I am new to java and I can't figure out what happened to this block of code. I know the array is not null. I am testing it elsewhere. There may be a syntax issue that I use for programming 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] "12345"
employeeIdthere is "12345"
but I cannot enter the first if statement, although employeeIdIS is equal employeeNumber[0].
source
share